adding force to instantiated ragdoll

Hello Unity-Community,

I've managed to create a ragdoll via ragdoll-wizard and it works so far. Now I'm trying to add force to the instantiated ragdoll because the enemy is shot but it only collapses on the spot.

Here is my script which is attached to the enemy:

var deadReplacement : Transform;

function Update()

function replaceWithRagdoll() 
    // Destroy ourselves

    // Replace ourselves with the dead body
    if (deadReplacement) 
        var deadBody = Instantiate(deadReplacement, transform.position, transform.rotation);
        deadBody.rigidbody.AddForce(transform.forward * 1000);

I would really appreciate a hint why it is not working

greetings Pengu

I’m sorry to reply just now but we made a tool for the asset store that shows how to do this even in the awesome and feature full free version (forum thread and links here), that I’d suggest you install to get a number of leads on how to properly ragdoll and interact with game models and physics.

Besides, you basically need to ‘intercept’ the collider or trigger event, and add a relative force in the point of contact, like this

rigidbody.AddForceAtPosition(myforce,myimpactpoint, myforcemode);

which basically adds a force to the rigidbody into a point, causing torque and translation. Note in fact that the forcemode is very important, since it determines the kind of impulse that the rigidbody will receive.

You've set the instantiate pointer to a transform i.e. a set of coordinates and scales.

What you need to do is set the instantiate pointer to a GameObject prefab.

var deadReplacement : GameObject;

Then you drag your ragdoll into an empty prefab to save it.

Then you drag the prefab onto the deadReplacment slot in the inspector.

Make sure that the root object of the ragdoll prefab has a rigid body as you're trying to access it.

weird, setting the instantiate pointer to a GameObject prefab didn't make any difference for me but

Make sure that the root object of the ragdoll prefab has a rigid body as you're trying to access it.

ringed the bells!

my mistake was that I didn't access the ragdoll root bone directly (or which ever part I wanted to push)

instead of


deadBody.rigidbody.AddForce(transform.forward * 1000);

I did


gameObject.Find("ragdoll_pelvis").rigidbody.AddForce(-transform.forward * 1000)

"ragdoll_pelvis" = name of my root object / -transform = to push him backwards

and it worked!

thanks for the help spinaljack :)

You should use `AddRelativeForce` so that the ragdoll moves relative to the direction it has been hit from. The syntax is the same as add force. Its just that if it is shot from the left it will fall to the right, rather than always falling in one direction.