A* Pathfinding Project

AIPath.steeringTarget doesn't update


#1

Please help :slight_smile:
I’m trying to do a rootmotion with AIPath and the problem is I need to calculate a desiredVelocity , that actually always v3.zero if use AIPath.desiredVelocity, Im trying to do it like that

        Vector3   desiredVelocity = (a_Unit.Agent.steeringTarget - a_Unit.m_transform.position).normalized;

        Vector3 velocity = Quaternion.Inverse(a_Unit.m_transform.rotation) * desiredVelocity;

        float angle = Mathf.Atan2(velocity.x, velocity.z) * S_Number.angle180 / Mathf.PI;

        locomotion.Do(velocity.magnitude, angle, distanceToDestination);

Everything is fine except steeringTarget, it always stuck on first or nearest point and never reach just walking around even if I set PickNextWayPoint to some very big number.


#2

Hi

Have you possibly disabled ai.canMove or something like that?


#3

yes, that what I did


#4

Then it will not update those variables anymore. If you turn off canMove it will skip those calculations for performance reasons.

If you want to override the movement completely you could follow the example here:
https://arongranberg.com/astar/docs/iastarai.html#MovementUpdate

Also, you might be interested in checking out the script called MecanimBridge in the project. It is not implemented in any example scene yet, but it shows how to get rudimentary root motion working.


#5

Thank you Aron, that’s very helpful!