using System; using UnityEngine; public class Projectile : MonoBehaviour { public Entity owner; public float damage; public float lifetime; private int currentPierced; public int pierceAmount; public float speed; [SerializeField] private Rigidbody2D rb; public Vector2 direction; private void Start() { Destroy(gameObject, lifetime); direction = transform.right * speed; } private void FixedUpdate() { rb.linearVelocity = direction; } private void OnTriggerEnter2D(Collider2D other) { if (!other.CompareTag(tag) && other.TryGetComponent(out Entity isEntity)) { isEntity.stats.TakeDamage(damage); currentPierced++; if (currentPierced > pierceAmount) { Destroy(gameObject); } } else if (other.gameObject.layer == 3) //hard coded layer but who tf cares i'm not inputting the variable every time i make a projectile lol { Destroy(gameObject); } } }