How can i set gameobject to inactive аfter delay on CollisionEnter

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;
}