I am new to Unity development. I started learning Unity by reading tutorials, demos, examples, and watching videos. And I am having some trouble with using this timer. Here is my code:
void OnCollisionEnter(Collision colli){
if (colli.collider.name == "Car") {
Debug.Log("On Collision naz ~.~");
Destroy(Car);
Destroy(this.gameObject);
GameObject clone = (GameObject) Instantiate(Bum, transform.position, Quaternion.identity);
StartCoroutine(deleteObject(clone));
// Just want to delete "clone" object after 1 second
}
}
IEnumerator deleteObject(GameObject bum){
Debug.Log("chuan bi destroy naz ~.~"); // <-- run normally
yield return new WaitForSeconds(1.0F);
Debug.Log("Destroy rui naz =,='"); // <-- not display
Destroy (bum);
}
Why won't this object be destroyed after 1 second?