using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class Bullet : MonoBehaviour { [SerializeField] private int _damage; public int Damage => _damage; // Speed in m/s [SerializeField] private float _speed; public float Speed { get { return _speed; } set { _speed = value; } } [SerializeField] private Vector2 _direction; public Vector2 Direction { get { return _direction; } set { _direction = value; } } private void Start() { Mover mover = GetComponentInParent(); if (mover == null) { throw new MissingComponentException("Missing Mover!"); } mover.Direction = Direction; mover.MaxSpeed = Speed; } // Destroy on Stay, collision effects should be handled on Enter private void OnCollisionStay2D(Collision2D other) { Destroy(gameObject); } private void OnBecameInvisible() { Destroy(gameObject); } }