I'm making this 2D platform based game. Basically what I want is when the player walks into spikes (which have a "deadly" tag") it displays the animation that has the parameter of animate with the value of 3 and after that the player gets destroyed. So my question is:
- How do I build a timer or something so that the object only gets destroyed after the animation is played (with no looping)?
This is the code I'm using now:
void OnTriggerEnter2D(Collider2D target) {
if (target.gameObject.tag == "Deadly") {
Die();
}
}
void Die() {
animator.SetInteger ("AnimState", 3);
Destroy (gameObject);
}
No comments:
Post a Comment