Forum rules - please read before posting.

Help with animator with "Apply root motion". (Gravity not working)

edited September 2016 in Technical Q&A
 I have a player with the "Apply root motion" option on, and a Root Motion Node set to my armature's root.

 It appears that with this setup,  the animator applies the in-place position after every frame and puts it back to previous Y, making it so that the Rigid Body's gravity doesn't do practically anything (actually, the character starts levitating if mass set to less than 1000, and if not grounded falls very, VERY slow).

 After a little bit of research I've managed to partially solve the issue adding a few lines to "Player.cs" _Update();

            if (IsGrounded ())

            {

                KickStarter.player.GetAnimator ().applyRootMotion = true;

            } 

            else 

            {

                KickStarter.player.GetAnimator ().applyRootMotion = false;
            }

 This way, the apply root motion deactivates when the player is not grounded and he/she falls properly; however, it doesn't work on uneven terrains or slopes (even a 5 degree slope makes the character fall down the slope very fast); I guess my "fix" doesn't work with how the "IsGrounded" bool of AC checks its value; but I know very little about scripting or coding, so any help in this matter would be greatly appreciated.

Comments

  • It may be that you need to change your animation import settings, rather than manipulating properties through script - my own testing with root motion and the character animations in Unity's Standard Assets haven't had such an issue, though I did need to fiddle around with the Root Transform Position (Y) section of the animation settings - checking Bake Into Pose in particular.
  •  I've tested yout solution and it works, sadly it only is avaiable if you're not setting any specific node to act as the root motion source (as the "bake Y into pose" setting only appears that way).

    image

     I'll still fiddle a little bit with the code to see if I can get it
    to work because I prefer to have more control over the root motion. But it won't be that much of a pain to use your solution. Thanks for the answer!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.