A* Pathfinding Project

Root motion with A*?


#1

How can I sync mecanim root motion with A*?

I tried using Ootii Motion controller to handle the animation but it doesn’t use root motion.

I dont need obstacle avoidance/rvo.

I tried using MecanimBridge, but it seems there is no speed variable, so they always run?
Magnitude is either 1 or 0, with no variation in between.
Do I need to edit it and get the value from Behavior Designer?

When I use MecanimBridge, it just looks bad - particularly when it rotates:
https://gyazo.com/a7e607e56eb06f82f4781e60628fb0d7


#2

No one uses Mecanim with A*?


#3

For simple root motion, you only need this and Im currently trying to get it working with RVO. I also had to set my RichAi max speed to 0.01 and rotation speed to 90, also turn off Slow When Not Facing Target

     private void OnAnimatorMove()
    {
        if (Time.deltaTime <= 0) return;

        Vector3 nextPosition;
        Quaternion nextRotation;

        _richAi.MovementUpdate(Time.deltaTime, out nextPosition, out nextRotation);
        _richAi.FinalizeMovement(new Vector3(_animator.rootPosition.x, nextPosition.y, _animator.rootPosition.z), nextRotation);

    }

rr


#4

Thank you - I will try this!


#5

Oh. @juststan. I’m not sure where you originally found that code that you are using, but you are missing one important piece. You need to set ai.canMove = false, otherwise the agent will try to move by itself as well. That’s probably why you have had to set the max speed to 0.01 (which you really shouldn’t have to do).

Here is some example code for it which does include that setting: https://arongranberg.com/astar/docs/aibase.html#MovementUpdate


#6

If you have canMove = false and the MaxSpeed = 0, the agent wont navigate, it will walk in a straight line.

Setting the MaxSpeed to 1 seems to work, but if I set it to 1000 or 10,000 the navigation is completely broken, so this still affects the navigation somehow even if canMove is false. Hopefully if it stays 1, there won’t be any problems.


#7

There are some cases when it is used indirectly yes. But just as long as it is a reasonable value then I think it should be ok.