Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
enemy fire interaction
Player _player;
private float _speed = 8f;
// Start is called before the first frame update
void Start()
{
_player = GameObject.Find("Player").GetComponent<Player>();
}
private void OnTriggerEnter2D(Collider2D collision)
{
if(collision.tag == "Player")
{
_player.Damage();
Destroy(gameObject);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment