using System.Collections; using System.Collections.Generic; using UnityEngine; public class Bullet : MonoBehaviour { public Rigidbody2D rb; [System.NonSerialized]public int setDmg; private int Damage; private void Start() { Damage = setDmg; rb.AddForce(Vector2.right * 20); } private void OnCollisionEnter2D(Collision2D other) { if(other.collider.CompareTag("Player")) { return; } if(other.collider.TryGetComponent(out Health health)) { health.RemoveHP(Damage); } GameObject.Destroy(gameObject); } }