RichAI with joystick

The game requires players to move through a 3D scene using a joystick. My current solution is to use RecastGraph and RichAI for navigation. However, I’ve found that I can’t directly use ai.Move() because it doesn’t keep the character within the walkable area, similar to the constrainInsideGraph feature in AIPath. Analyzing the source code of RichAI.ClampToNavmesh(), I found that using ai.Move() directly in RichAI does not assign a value to RichFunnel.

The solution I’ve tried is to have to assign a value to ai.destination in the update to ensure that the character stays within the walkable area, but I’m concerned about the performance issues. Additionally, no matter how I set maxSpeed and Acceleration, the character moves very slowly.

I’m currently using version 4.2.19, and my code is as follows:

Void Update(dt)
{
     Vector3 InputMovementReference = direction * force * dt;
      _aiPath.destination = transform.position + InputMovementReference;
      if(!_aiPath.pathPending)
         _aiPath.SearchPath();
}

I need to confirm how to correctly use the joystick for movement, which has been troubling me for a long time.

Hi

You can take a look at this tutorial, which I just added to the beta: Manual Player Movement - A* Pathfinding Project :slight_smile:

Be mindful of what you set the “slowdown time” or “slowdown distance” (depending on movement script) to. If you set it too low, the agent will move very slowly because the destination that you set will always be pretty close to the agent.