using Unity.BossRoom.Gameplay.GameplayObjects.Character; using UnityEngine; using Unity.Netcode; public class FreezeThrowPrefab : NetworkBehaviour { private Vector3 direction; private float speed; private float freezeDuration; private ServerCharacter owner; public void Initialize(ServerCharacter character, Vector3 direction, float speed, float freezeDuration) { this.owner = character; this.direction = direction.normalized; this.speed = speed; this.freezeDuration = freezeDuration; } private void Update() { if (IsServer) { transform.position += direction * speed * Time.deltaTime; // Check for collision or expiry if (Vector3.Distance(transform.position, owner.transform.position) > 20f) { NetworkObject.Despawn(); } } } private void OnTriggerEnter(Collider other) { if (!IsServer) return; if (other.TryGetComponent(out ServerCharacter target)) { if (target != owner) { Debug.Log($"[FreezeProjectile] Hit {target.name}. Applying freeze for {freezeDuration} seconds."); target.Freeze(freezeDuration); NetworkObject.Despawn(); } } } }