Quantcast
Viewing latest article 4
Browse Latest Browse All 90

Destroying the cloned gameObject

How could I find the name of the cloned gameObject that is instantiated so I can destroy it after a certain amount of seconds? 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(); R.CopyPose (transform); Destroy (this.gameObject); } }

Viewing latest article 4
Browse Latest Browse All 90

Trending Articles