I have my game initiating a restart upon contact with my “kill” objects, however I want to delay the restart in order for the player to view the ragdoll effect I have. So in short I want the character to make contact with my kill object, then allow the ragdoll to perform and then the game restarts. I’m new to C# and unity so forgive my ignorance. I’ve seen a lot of suggestions to coroutines however I’m unsure of how to implement this into the code as I have it written. Any help is greatly appreciated.
here is the code
using UnityEngine;
using System.Collections;
public class Entity : MonoBehaviour {
public float health;
public GameObject ragdoll;
public void TakeDamage(float dmg) {
health -= dmg;
if (health <= 0) {
Die();
}
}
public void Die() {
Ragdoll r = (Instantiate(ragdoll,transform.position,transform.rotation) as GameObject).GetComponent<Ragdoll>();
r.CopyPose(transform);
Destroy(this.gameObject);
}
}