Quantcast
Channel: Questions in topic: "ragdoll"
Viewing all articles
Browse latest Browse all 565

Set the ragdoll position

$
0
0
Hi, I have a soldier's gameobject, and when his health goes to 0 I destroy this gameobject and I replace it with a soldier's ragdoll, the problem is that I want that the instantiated ragdoll has the same position and rotation (also for every child like arms,legs ecc..) of the precedent gameobject, but my script doesn't work because the ragdoll is istantieted in the t-pose... How could i adjust it? var ragdoll: Transform = Instantiate(replacement, transform.position, transform.rotation); var currentJoints= GetComponentsInChildren(Transform); var ragdollJoints=ragdoll.GetComponentsInChildren(Transform) for(var childRagdoll : Transform in ragdollJoints) { for(var childGameObject : Transform in currentJoints) { if(childGameObject.name.CompareTo(childRagdoll.name) == 0) { childRagdoll.position = childGameObject.position; childRagdoll.rotation = childGameObject.rotation; } } } Destroy(this.gameObject); Thanks in advice and sorry for my bad english!

Viewing all articles
Browse latest Browse all 565

Trending Articles



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