Quantcast
Channel: Latest Questions by Fox-Handler
Viewing all articles
Browse latest Browse all 90

Destroying the cloned gameObject

$
0
0
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 all articles
Browse latest Browse all 90

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>