Answer the question
In order to leave comments, you need to log in
How to set up enemy death in Unity 2d?
There is such C# code for Unity 2D
void OnCollisionEnter2D(Collision2D touch)
{
if (touch.gameObject.tag == "EnemyKill")
{
life = life - 1;
if(life <= 0)
{
rgb.AddForce(transform.up * speed, ForceMode2D.Impulse);
rgb.GetComponent<CapsuleCollider2D>().enabled = false;
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question