I want to add a die effect that when an enemy is dead the body bones act like a ragdoll
I wrote this to create the effect using Hinge joint (it’s just for left bone):
// wings are children of centerBody
// first 2 lines are for swapping the parenthood
function bodyDie(){
leftBone.transform.parent = centerBody.transform;
leftWing.transform.parent = leftBones.transform;
leftBone.AddComponent(Rigidbody);
leftBone.AddComponent(HingeJoint);
leftBone.hingeJoint.connectedBody = centerBody.rigidbody;
leftBones.hingeJoint.anchor = Vector3(0,0,0.4);
leftBones.hingeJoint.axis = Vector3(1,0,0);
}
this is weird! The code does not work in play mode. components are added correctly but there is no swinging effect(like fixed joint) but if i pause the game, change a value(for example turn useMotor on and then off) it starts acting physically correct…
anyone experienced this before? whats the problem?
Thanks you are right a little kick makes it work :)
– gharbill