Skip to content

Instantly share code, notes, and snippets.

@curious-username
Created October 3, 2021 02:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save curious-username/12a52a01c0deda4aa4d52742cbaf0e70 to your computer and use it in GitHub Desktop.
Save curious-username/12a52a01c0deda4aa4d52742cbaf0e70 to your computer and use it in GitHub Desktop.
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