How do you push a character in a direction but stay in the navmesh

Hello. Basicly it is copy of topic from 2017. I need a replace on NavMeshAgent.Move(Vector3)

Still decision from that topic didnt seem good to me, so i decided to ask, mb there is better way do same now ? I’m only exploring the asset now and i think, that many things are realy cool, but however i can not find so easy function…

SOLUTION: best solution, that i was able to find was use AIPath.Teleport(Vector3). It simply does what is supposed.

i’ll be really appreciate, if someone can help me with this question. I still can not find solution. And if there is no such function in this asset - i need to try find other instrument for my project :frowning:


The included agents also have a .Move function. You can use that.
See IAstarAI - A* Pathfinding Project

I tryed it on RichAI and AIPath. It didnt work, my character just ran out of moving ground(if i used destination = some_position all was fine) and fall from scene

Im trying to use joystick for controlling character. So input should be quite responsible. I tryed to work around with just setting destination every frame - it worked, character was inside mesh, obstacles are proper avoided, but it was not good. because had some latency.


For the AIPath you need to ensure it has “constrain to navmesh” enabled. For the RichAI, it probably needs a path, otherwise it will not know where on the navmesh it is.

Did you try lowering the repath rate? For a joystick controlled character you might want to set that as low as 0.

If you use a joystick for controlling the character, you might not want one of these AI scripts at all. They are indended for moving along paths, not being controlled via a joystick.

Basicly i just want player controlled from joystick to be able move in walkable space. Mb there is some other solution for it in this asset?

There are two main approaches:

  1. You can set the destination of the agent like you are doing it now.
  2. You can write a custom script which moves the agent using joystick input and then clamps the agent to the navmesh using every frame.

I would probably recommend (1), but it depends on your game and the feeling that you want.

Oki, thank you for response. Ill try a bit more to solve it some way. Otherwise of this just want to add that you made great work on this asset.

Looks like i found proper solution. AIPath.Teleport works just fine. I updated topic for future seekers.

1 Like