Hi, here is code
void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.name == “Enemy”)
{
heroAnimator.SetBool("Dead", true);
hero.active = false;
}
}
How can i add delay before active = false?
Hi, here is code
void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.name == “Enemy”)
{
heroAnimator.SetBool("Dead", true);
hero.active = false;
}
}
How can i add delay before active = false?
private float delaytime = 3f;
void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.name == “Enemy”)
{
heroAnimator.SetBool(“Dead”, true);
StartCoroutine (delayactiv());
}
}
IEnumerator delayactiv()
{
yield return new WaitForSeconds (delaytime);
hero.active = false;
}