Search Unity

Disable IK Pass with code?

Discussion in 'Scripting' started by Kovenant, Sep 19, 2017.

  1. Kovenant

    Kovenant

    Joined:
    Sep 18, 2013
    Posts:
    254
    I'm following the Merry Fragmas 3.0 tutorial and it's going quite well.. except for the fact that I'm using different models, so it doesn't look exactly the same.

    ...when a player dies and it plays the death animation the arms of the player gets all screwed up due to the Inverse Kinematics. Can I disable IK on a specific animation so this doesn't happen?
     
  2. RoMax92

    RoMax92

    Joined:
    May 29, 2017
    Posts:
    135
    You can create a code who can modify the kinematic paramether in real time, or do a ragdoll with another animation on it, or better, a ragdoll with phisics
     
  3. Kovenant

    Kovenant

    Joined:
    Sep 18, 2013
    Posts:
    254
    How does Ragdolls work? Do I make a duplicate of my soldier model and make that a ragdoll which I instantiate at the soldiers position upon death?
     
  4. RoMax92

    RoMax92

    Joined:
    May 29, 2017
    Posts:
    135
    Exactly as you said
     
    Kovenant likes this.
  5. Kovenant

    Kovenant

    Joined:
    Sep 18, 2013
    Posts:
    254
    @RoMax92
    Don't know if you ever did the Merry Fragmas 3.0 tutorial, but I can't get it to work..
    I've removed all the scripts from my soldier duplicate, I set up the ragdoll and put a Network Identity on it.
    I put my ragdoll prefab in the "Registered Spawnable Prefabs" in the Network Manager.

    So far, so good..

    When the client kills the server, the ragdoll instantiates - however, it instantiates three ragdolls instead of only one.
    The next problem is that when the server kills the client, one ragdoll is instantiated but it freezes in mid-air and throws an NullReferenceException error: "
    I instantiate the ragdoll with this:
    Code (CSharp):
    1.     public void Die()
    2.     {
    3.         GameObject ragdoll = (GameObject)Instantiate(soldierRagdoll, transform.position, transform.rotation);
    4.         NetworkServer.Spawn(ragdoll);
    5.  
    6.  
    7.         DisablePlayer();
    8.         Invoke("Respawn", respawnTime);
    9.     }
    Is the Die() function the wrong place to instantiate the ragdoll? What am I doing wrong here?

    Edit: Noted the exception error throws even if it is the client killing the server, didn't notice that before
     
    Last edited: Sep 19, 2017
  6. RoMax92

    RoMax92

    Joined:
    May 29, 2017
    Posts:
    135
    I never did this tutorial :/

    When the client and the server are on, all is good? If yes is a network problem, before you istantiate the ragdoll you can check if the connection is good.

    Yes, remember to destroy the player or the mesh with the interacteble script. Maybe invoke the respawn first, for prevent bugs.