News Forums RAIN General Discussion and Troubleshooting Root motion and gravity

This topic contains 2 replies, has 2 voices, and was last updated by  kzoink 2 years, 8 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #5320

    kzoink
    Participant

    So after having solved my problems with the standard behavior of MecanimMotor by deriving from it and creating my own custom motor as detailed in this thread, I’ve now run into another problem-my AI tends to float for a while after going up and over a bump or ramp in terrain. Yes, unlike problems I’ve read in other threads, my AI are properly going UP the ramp, but when going back down, they walk into the air and it takes a while for them to reach the ground IF and only IF they are moving, which leads me to suspect that the root motion code is fighting with the RigidBody that is trying to apply gravity. I suspect this is the case because I noticed that during a stop or turn, when speed = 0, the character will fall to the ground quickly because of gravity.

    Here’s some background on my setup:

    I’m using RAIN v2.05 for now as I encountered bugs in the v2.06 release.

    I’ve got a Mecanim humanoid character with a Capsule Collider and a RigidBody with Mass set to 60, Use Gravity checked, Is Kinematic unchecked and Freeze Rotation set on X, Y and Z. The transform of the parent object is at the feet of the character, and the bottom of the capsule collider is at that point as well. All other values are at the default.

    I’ve got a very simple Mecanim Controller with Idle, Walk and Run states. Apply Root Motion is checked in the Animator component.

    My walk and run animations have root motion.

    I’m using my custom motor derived from MecanimMotor, and the MecanimAnimator on my AI rig. The only Mecanim parameter that is being driven is Speed. Speed controls whether we transition to Walk or Run states which are just states with a single animation. As mentioned in my thread about my custom MecanimMotor, I have overridden the default behavior of the MecanimMotor such that root motion is used for linear/forward motion and the AI is in control of the rotation/angular motion.

    With all that said, I’m wondering if I could get a comment from @prime on how to properly reconcile root motion with a rigid body and capsule collider setup? I’ve been able to piece together as much as I have from bits and pieces on this forum and my past experience with Rain{Indie}, but it hasn’t been easy.

    #5323

    prime
    Keymaster

    I still have a Mecanim tutorial in the works (along with a sample project). However:

    - When using Root Motion with Mecanim and RigidBody, just make sure you have rigid body constraints set on all your Rotation axis, but not on any of your position axis.
    - Make sure your Motor isn’t interfering with AI transforms - at least for position. The MecanimMotor doesn’t by default, as long as you have the Use Root Motion box checked.
    - If you post your motor, or send it to us directly, I can take a look and comment.

    #5359

    kzoink
    Participant

    I was able to solve the problem by going into the animation clip and checking “Bake Into Pose” for the Root Transform Position (Y).

    My AI now go up and down ramps successfully without issue.

    • This reply was modified 2 years, 8 months ago by  kzoink.
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.