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

How do i DISABLE rig ik AND humanoid animation for ONLY A SPECIFIC LIMB, like l

Discussion in 'General Discussion' started by ProCode1560, Aug 14, 2023.

  1. ProCode1560

    ProCode1560

    Joined:
    Mar 31, 2019
    Posts:
    5
    I have a character.

    The characters limbs have been setup with collider, rigid body and character joints.

    The character has 1 animator for humanoid animations such as walking, running, that apply animation to the whole body, arms, legs, etc. and then ive also got another separate RIG animator, that basically does IK for arms, when grabbing objects so it overrides the humanoid animation.

    #1 Animator for the walking, running and idle FULL BODY animation. Simply has a blend state.
    upload_2023-8-14_14-1-8.png
    #2 Animator that plays rig IK animation, that overrides the FULL BODY animation, like walking, so that walking animation is still playing but only the arms have IK animation playing.
    upload_2023-8-14_14-2-17.png

    So with that in mind, how would i go about enabling RAGDOLL FOR A SPECIFIC limb, like the left arm only, meaning the humanoid animation shouldn't be applied FOR THE SPECIFIC limb or should be overridden by the ragdoll.
    Same goes for the rig animation, thats animating the ARM with IK.

    HERES A DRAWING TO SHOW WHAT THE ANIMATORS DO AND WHAT ID LIKE TO HAPPEN.
    upload_2023-8-14_14-18-3.png


    TLDR: I WANT to disable rig IK ANIMATION and HUMANOID ANIMATION for only a specific limb !

    Here's current solutions im thinking of: LET ME KNOW IF YOU HAVE BETTER ONES

    Solution 1 from: https://discussions.unity.com/t/ignore-bones-in-animation/55262

    https://docs.unity3d.com/ScriptReference/AnimationState.RemoveMixingTransform.html

    1. REMOVING SHOULDER TRANSFORM OF THE ARM I WANT TO HAVE RAGDOLL from the animation state in the animator
    However im struggling to implement this, for some reason it keeps on saying object ref is not set to instance of object, i believe coz of the "anim["ANIM_STATE_NAME"].removemixingtransform(SHOULDER)" line, but i dont know why...

    NOT YET FAIL? need help

    2. Making multiple animation layers with different avatar masks, like one layer might have an avatar mask with left arm disabled, but this solution is very time consuming and seems like a stupid way to go about doing what i want.

    FAIL?

    3. I were thinking of changing avatar mask during run time, but doesnt seem possible currently with unitys defualt animator animation thingy.

    FAIL?
     
  2. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,317
    First, see if this is related:
    https://docs.unity3d.com/Packages/com.unity.animation.rigging@1.1/manual/index.html

    Beyond t hat, I believe the idea is to make an invisible fake limb acting as ragdoll, and then you either copy limb transform onto skeleton (either by overriding transform, or through IK), or you make original animation invisible, and copy it onto actual mesh.

    Also see Dynamic Bone asset and how that one works.
     
  3. ProCode1560

    ProCode1560

    Joined:
    Mar 31, 2019
    Posts:
    5
    Thats interesting, so u are saying to make an invisible limb and let it do its thing, and then copy the transforms and override them to the skeleton arm limbs, hmmm thats interesting and i think that is doable
     
  4. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,317
    Yes. It is a dumb solution, but it will work.

    The thing here is that if you copy transforms directly onto rig being animated by animator, the animator is going to fight your changes. As a results either go here:
    https://docs.unity3d.com/Manual/ExecutionOrder.html

    And see if you can overwrite animator animations right after it is done animating...

    Or make a "puppet rig". In which case you'll have an "invisible" rig animated with animator, and you'll selectively copy it onto "puppet" rig yourself, in which case you'll be able to ragdoll anything you want. That'll cost you CPU cycles, for the record, but not too many.

    There may be a better way to do it, but you should try asking in the right forum. General section is not a support forum. Some people wander in and ask questions, but you should probably head here:
    https://forum.unity.com/forums/animation.52/
     
  5. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,874
    Animation rigging package is built for stuff like this, use that