using UnityEngine; public class PlayerArrow : MonoBehaviour { private float damage; private float speed; private float range; private Vector3 startPos; private bool isFired = false; public void Initialize(float dmg, float arrowSpeed, float maxRange) { this.damage = dmg; this.speed = arrowSpeed; this.range = maxRange; this.startPos = transform.position; this.isFired = true; Rigidbody rb = GetComponent(); if (rb != null) { rb.useGravity = false; // Á÷¼± ¹ß»ç rb.velocity = transform.forward * speed; } Destroy(gameObject, 5f); // 5ÃÊ µÚ ÀÚµ¿ »èÁ¦ } void Update() { if (!isFired) return; if (Vector3.Distance(startPos, transform.position) >= range) { Destroy(gameObject); } } private void OnTriggerEnter(Collider other) { if (other.CompareTag("Enemy")) { var monster = other.GetComponent(); if (monster != null) monster.TakeDamage(damage); Destroy(gameObject); } else if (other.CompareTag("Wall") || other.CompareTag("Ground")) { Destroy(gameObject); } } }