Search Unity

How to fix animation 'Gravity Weight' issue with Root Motion [SOLVED]

Discussion in 'Animation' started by neill94, Nov 22, 2016.

  1. neill94

    neill94

    Joined:
    Mar 3, 2013
    Posts:
    6
    Hi everyone,

    I've recently found a solution to a problem I was having with root motion animations, where their gravity weight was set to 0 instead of 1 (animator.gravityWeight). This was resulted in the character floating when walking down ramps/stairs.

    After some digging around, I managed to find a great solution which I found quite hard to find and isn't well documented, so I thought it would be great to share here if anyone else in the future experiences a similar issue.

    As seen in the attached image below, simply go to each of your animations used and add a Curve with the name 'GravityWeight' and set the value to 1, then change the curve to a straight line as shown below.

    Press apply and you should be good to go! :)

    f8568c7fdae401e5763d77a8ddfa7737.png
     
  2. John3D

    John3D

    Joined:
    Mar 7, 2014
    Posts:
    441
    Thanks for sharing.
     
  3. Kaldrax

    Kaldrax

    Joined:
    Sep 14, 2017
    Posts:
    44
    THANK YOU!!! <3333
     
    neill94 likes this.
  4. Un3mp

    Un3mp

    Joined:
    Jan 23, 2018
    Posts:
    2
    Thank you! I had been looking everywhere on the internet and this was the solution.
     
    neill94 likes this.
  5. sickbattery

    sickbattery

    Joined:
    Jul 13, 2014
    Posts:
    20
    Thanks a lot ... but now I have to fix a ton of animation clips ... is there a way to fix it for all at once?

    Edit: Nevermind, took me just >40min to do -.- ... ...
     
    Last edited: Mar 28, 2018
    joeee19 and BidhanBhuwai like this.
  6. AlphaNoir

    AlphaNoir

    Joined:
    Jun 8, 2018
    Posts:
    2
    Thanks!!
     
  7. turritom

    turritom

    Joined:
    Mar 22, 2013
    Posts:
    113
    thank you very much !!! since years i search for a solution for this "bug" thanks again :)
     
  8. Eudaimonium

    Eudaimonium

    Joined:
    Dec 22, 2013
    Posts:
    131
    It's two years later, the end of 2018 and I have used this fix to fix my floating enemies that were driven by a NavMeshAgent and an animator root motion (no custom physics movement on my side).

    The clips I were using for locomotion didn't have the additional clip options (this is normally fixed by baking Y into pose, but these didn't have that), I'm gonna have to research why do some animation clips have those and some don't.

    What I'm curious about, is how did you manage to figure out that naming an animation curve with a specific string will fix this? Seriously, how did you arrive at this solution?
     
  9. RogueMacro

    RogueMacro

    Joined:
    Nov 16, 2017
    Posts:
    2
    Still working, even its almost mid-2019. Best post I have ever come across!
     
  10. wakawa2003

    wakawa2003

    Joined:
    Nov 29, 2018
    Posts:
    2
    love you :v
     
  11. prince564813

    prince564813

    Joined:
    Jun 8, 2017
    Posts:
    2
    Helped me too. Cheers
     
  12. Radagast37540

    Radagast37540

    Joined:
    Oct 1, 2018
    Posts:
    1
    Thank you soooo much, it was driving me crazy !
    (Love Unity and CharacterController, this fixed its only limitation I found)
     
  13. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    504
  14. Yusufhabib

    Yusufhabib

    Joined:
    Apr 29, 2018
    Posts:
    3
    thank you so much
     
  15. Zardify

    Zardify

    Joined:
    Jul 15, 2015
    Posts:
    20
    I know this is years old... But anyone managed to figure this out? Seems like only animations imported from an FBX file have Curves options in their inspector... :(
     
  16. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    504
    If you are using imported animations see if setting them as "Humanoid" helps (it's under the rig tab)

    If you are using animations generated within unity (they have the file extension .anim) I think you can add the curve directly in the animation (by using the "animation" window). But I never tried it personally. The reason I think it will work is I've seen some of my animations complain about the missing "GravityWeight" curve in my animation files (seen this in the animation window, there was a GravityWeight entry written in yellow like when you delete a transform that was animated but leave its animation curve behind).

    Good luck :D
     
  17. Zardify

    Zardify

    Joined:
    Jul 15, 2015
    Posts:
    20
    True, I arrived at the same conclusion myself. In the case of .anim files, it's probably the exact same thing adding them directly on the animation window as it is adding them under Curves for imported ones. Difference is though, the animation window doesn't allow adding GravityWeight at all ... :eek: Because it's a "Missing poperty" even on an imported animation, you can't even add it on a .anim file :D.

    I've since gave up on this method. I have a feeling it's not the route one should take for jumping so... Thank you for the response!
     
  18. Sanjay112000

    Sanjay112000

    Joined:
    Nov 9, 2020
    Posts:
    10
    Thank you bro
     
  19. SketchyRodent

    SketchyRodent

    Joined:
    Jan 4, 2020
    Posts:
    9
    Having a similar occurrence that stemmed from testing out the Timeline feature on one of my sprites.
    Not too sure on the specifics of how, but the timeline somehow altered the animation controller so that any sprite using it is no longer affected by gravity. This remained an issue even after removal of the timeline component. The working fix seems to be make a new controller (the animations thankfully seem to be unaffected).

    Hope this helps others out there that wound up with levitating sprites after playing around with Timeline.
     
  20. ngerbens

    ngerbens

    Joined:
    Nov 20, 2017
    Posts:
    33
    Is there any solution for animations made within Unity, where you can't add a curve or float?
     
  21. JARVIS843

    JARVIS843

    Joined:
    Aug 14, 2020
    Posts:
    1
    Unity 2021 LFS here. If this is not working for you, try baking the transform position Y and then do it. Baking works for me.
     
  22. graham30

    graham30

    Joined:
    Oct 17, 2019
    Posts:
    5
    2022 and this still works! Thanks dude!
     
  23. VladimirMacoun

    VladimirMacoun

    Joined:
    Jul 10, 2017
    Posts:
    6
    This is perfect. I think it is related with baking y pose. Thanks.
     
  24. devagold

    devagold

    Joined:
    Jun 19, 2020
    Posts:
    1
    I try this didn't work. So in motion selection select root motion node as <root transform>. Thats works for me.
     
  25. TMPxyz

    TMPxyz

    Joined:
    Jul 20, 2012
    Posts:
    766


    In the Animation import settings, tick the "bake into pose" for "Root Transform position(Y)", then the gravity will work on the model.

    For other component settings:
    • Animator:
      • apply root motion
      • animate physics
      • update mode => fixed
    • Rigidbody
      • use gravity : true
      • is kinematic : false
      • freeze rotation: x y z
    rootmo.jpg
     
  26. Devs007

    Devs007

    Joined:
    Sep 28, 2022
    Posts:
    5
    How can i fix when Animal with 4 legs moving with Navmesh Agent component, Issue is when its moving on ramp link in terrain bumps, its legs front legs or rare legs seems in air, because of NavMesh component, as itsin middle, but i want it to move like all legs should be on ground?