using UnityEngine; public class Bullet : MonoBehaviour { public float speed = 8f; private Rigidbody rb; public GameObject effect; public bool isPlayerBullet = false; void Start() { rb = GetComponent(); rb.linearVelocity = transform.forward * speed; Destroy(gameObject, 3f); } private void OnTriggerEnter(Collider other) { if (other.CompareTag("Shield")) { return; } if (other.CompareTag("Player")) { if (!isPlayerBullet) { Instantiate(effect, other.transform.position, Quaternion.identity); PlayerController pc = other.GetComponent(); if (pc != null) { pc.Die(); GameManager.instance.PlayDeathMusic(); } Destroy(gameObject); } return; } if (other.CompareTag("Spawner")) { if (isPlayerBullet) { Destroy(other.gameObject); Destroy(gameObject); } return; } } }