- Home /
Ragdollize kinematic rigidbodies
Hi there!
I have spent an entire afternoon (again) trying to figure out how to ragdollize kinematic armatures after being hit by a projectile.
First i set it to kinematic with :
function Start () {
var allChildren = gameObject.GetComponentsInChildren(Rigidbody);
for (var child : Rigidbody in allChildren) {
child.rigidbody.isKinematic = true;
}
}
Than i tried 2 methods: first is doing it in the ragdolls script:
function OnCollisionEnter ( hit : Collision){
if(hit.gameObject.layer == "Projectile"){
var allChildren = gameObject.GetComponentsInChildren(Rigidbody);
for (var child : Rigidbody in allChildren) {
child.rigidbody.isKinematic = false;
}
}
}
Didnt work. After that tried doin it from the projectiles script:
function OnCollisionEnter ( hit : Collision){
Destroy (gameObject);
Debug.Log(hit.gameObject);
var allChildren = hit.gameObject.GetComponentsInChildren(Rigidbody);
for (var child : Rigidbody in allChildren) {
child.rigidbody.isKinematic = false;
The debug worked ,so the hit. method must work somehow...( If i put only hit.rigidbody.isKinematic = false; here it worked ,but only on that bone, so a solution could be to get this to work on its parents and children aswell.)
After that tried calling the script on the ragdoll:
function OnCollisionEnter ( hit : Collision){
Destroy (gameObject);
Debug.Log(hit.gameObject);
hit.gameObject.SendMessage("kinematic.Ragdollize");
And this on the ragdoll:
function Ragdollize () {
var allChildren = gameObject.GetComponentsInChildren(Rigidbody);
for (var child : Rigidbody in allChildren) {
child.rigidbody.isKinematic = false;
}
}
I cant get it to work. Im slowly going insane.(the fact that i have to type this in for the second time ,becouse the server dun'goof'd didnt help...)
Any help would be greatly appriciated.
Thanks.