x


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.

more ▼

asked Mar 26 '12 at 02:02 PM

Sir Mate gravatar image

Sir Mate
64 6 9 12

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5071
x2490
x1787
x193
x162

asked: Mar 26 '12 at 02:02 PM

Seen: 436 times

Last Updated: Mar 26 '12 at 02:02 PM