A* Pathfinding Project

Agent is not constrained to graph


#1

Hello. Im looking to get functionality similar to Unity’s NavMeshAgent.Move();.
I want to move agent manually through input but im unable to keep the agent clamped to the graph.

I am using RichAI as my agent and graph is RecastGraph.

Here is the code i am currently using, it works fine moving but it doesnt get constrained.

public void Move()
{
            agent.canMove = false;
            Vector3 nextPosition;
            Quaternion nextRotation;

            agent.MovementUpdate(Time.deltaTime, out nextPosition, out nextRotation);

            nextPosition = agent.position + movementVector.value; // movementVector is value from input.

            agent.FinalizeMovement(nextPosition, nextRotation);
}

#2

Hi

The method you are using is for having full control over how the agent moves. This happens after clamping to the navmesh.

If you want a function corresponding to NavMeshAgent.Move you could use RichAI.Move :wink: