Day 26 — Getting into VFX in Unity

private Animator _enemyAnim;
private Collider2D _collider;
void Start()
{
_enemyAnim = GetComponent<Animator>();
_collider = GetComponent<Collider2D>();
}
private void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Player")
{
_enemyAnim.SetTrigger("EnemyDeath");
_enemySpeed = 0;
_collider.enabled = false;
Destroy(this.gameObject, 3.0f);
}
else if (other.tag == "Laser")
{
_enemyAnim.SetTrigger("EnemyDeath");
_enemySpeed = 0;
Destroy(other.gameObject);
_collider.enabled = false;
Destroy(this.gameObject, 3.0f);
}
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store