Skip to content

Instantly share code, notes, and snippets.

@curious-username
Last active December 31, 2021 15:05
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/0b7cacb493962e827a9821c6c51cae06 to your computer and use it in GitHub Desktop.
Save curious-username/0b7cacb493962e827a9821c6c51cae06 to your computer and use it in GitHub Desktop.
ontriggerenter2d
[SerializeField]
private GameObject _explosionPrefab;
private void OnTriggerEnter2D(Collider2D other)
{
if(other.tag == "Enemy_Laser")
{
Instantiate(_explosionPrefab, transform.position, Quaternion.identity);
Destroy(this.gameObject);
Destroy(other.gameObject);
Destroy(GetComponent<Collider2D>());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment