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

Instantiating a Ragdoll for use in another script

$
0
0
can someone tell me the difference between this Ragdoll R = (Instantiate (ragdoll, transform.position, transform.rotation) as GameObject).GetComponent(); R.CopyPose (transform); Destroy (this.gameObject); As opposed to just doing something like the latter. The component is still being accessed so what's the difference? using UnityEngine; using System.Collections; public class Entity : MonoBehaviour { public float health; public GameObject ragdoll; public Ragdoll R; public void Star () { R = GetComponent(); } public void TakeDamage(float dmg) { health -= dmg; if (health <= 0) { Die(); } } public void Die() { ragdoll = Instantiate (ragdoll, transform.position, transform.rotation) as GameObject; 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>