Replace game model by ragdoll

Hello

I want replace game model replace by ragdoll model after die unit. I create ragdoll model on start game and disable it.

After die unit:

  1. activate all ragdoll rigidbodies
  2. setup to all transforms in object tree as base game object transforms
  3. deactivate base game object

after this i have bug: root body in object position, other bodies in zero position.
How i can place correct ragdoll object in object position?

Hello,

Sorry could you be more clear? I kinda dont understand you :frowning:

Look at the FPS tutorial (part 3) in the Unity Support tutorials section:

http://unity3d.com/support/resources/tutorials/fpstutorial

There is a good explanation about using ragdolls :slight_smile:

Thanx by tutorial.

In this tutorial ragdoll create in death time. But on iPhone i cant create in this moment becouse game will lag.

I am create ragdoll object in start game, and want enable in death time.

You can deactivate only the render component of the ragdoll object until it is used and showed,(activating the render component again).

If i disable only render components game is more slow, becouse physics still working.

Optimal way by game speed:

  1. create ragdoll and disable object
  2. after die player - activate (resursive) ragdoll object and setup ALL TRANSFORMS (as in fps tutorial)

But i have one bug: root rigid body in normal position, but other rigidbodies in zero positions. Why?

If i instantiate ragdoll in death time - i have little lag.

Is there any confusion between world and local coordinates in the script? You might need to use transform.localPosition to position the child objects, rather than the usual transform.position (which works in world space).

No, i am correct setup transforms (as in tutorial) becouse if i instantiate ragdoll instead activate - program work fine (

It is may be bug in unity engine

It might be a bug, but is there any chance you could post the project? It would be useful to see exactly what is going wrong.

Yes, i create simple project to demonstrate this bug.

But, i found other way: my ragdoll object is still activated after start game in far position and after death player i only setup all transforms and deactivate player.

I found a solution to your problem (I post it even if the thread is old). The problem is that you must first enable the parents bones before the children. SetActiveRecursively activate before the children. To resolve this problem you can use this function:

void RecursiveDeepActivation (Transform trans)
{
trans.gameObject.active = true;

foreach (Transform t in trans)
{
RecursiveDeepActivation (t);
}
}

Thanks for the work around Nick, you are a life saver. I had the same problem

http://forum.unity3d.com/threads/77995-Problem-with-SetActiveRecursively-on-a-ragdoll?highlight=ragdoll

NickRichards, thank you so much for that - the inability to safely deactivate my ragdolls until I needed them was absolutely killing me.

At first, your solution didn’t quite work for me, but I realised it’s because my joint hierarchy doesn’t quite match my object hierarchy: in a few places (knees, elbows, etc) I have joints set up that aren’t actually parent/child relationships. By modifying your code a little bit to check for joints and to follow+activate their connectedBodies first, it all looks like it’s working now.

Cheers! :smile:

Thanks guys. This has been on my list for months. BUT, my activate/deactivate recursively was running the other way, so I had similar joint issues.

Hi. Regarding ragdoll transitioning, I wanted to let you know that our tool, the URG!, includes two classes, included in the free version of the tool too, to do exactly that, by means of a ragdoll prefab or by means of ‘kinetifying’.

Check my signature for direct access links (you will spot them easily down the page).