Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Replace game model by ragdoll

Discussion in 'Editor & General Support' started by dav, Sep 28, 2009.

  1. dav

    dav

    Joined:
    Jun 5, 2009
    Posts:
    22
    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?
     
  2. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hello,

    Sorry could you be more clear? I kinda dont understand you :(
     
  3. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,160
  4. dav

    dav

    Joined:
    Jun 5, 2009
    Posts:
    22
    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.
     
  5. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,160
    You can deactivate only the render component of the ragdoll object until it is used and showed,(activating the render component again).
     
  6. dav

    dav

    Joined:
    Jun 5, 2009
    Posts:
    22
    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.
     
  7. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    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).
     
  8. dav

    dav

    Joined:
    Jun 5, 2009
    Posts:
    22
    No, i am correct setup transforms (as in tutorial) becouse if i instantiate ragdoll instead activate - program work fine (
     
  9. dav

    dav

    Joined:
    Jun 5, 2009
    Posts:
    22
    It is may be bug in unity engine
     
  10. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    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.
     
  11. dav

    dav

    Joined:
    Jun 5, 2009
    Posts:
    22
    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.
     
  12. NickZangus

    NickZangus

    Joined:
    Oct 26, 2010
    Posts:
    13
    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);
    }
    }
     
  13. ratamorph

    ratamorph

    Joined:
    Sep 2, 2007
    Posts:
    458
  14. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,614
    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! :D
     
  15. Burke

    Burke

    Joined:
    Feb 7, 2010
    Posts:
    15
    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.
     
  16. The-Arc-Games

    The-Arc-Games

    Joined:
    Oct 3, 2011
    Posts:
    225
    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).