Page 1 of 1

AgentMoveToPosition problem

Posted: 2023/12/14 09:56
by frank_li
Hi,
I found some problems with the AgentMoveToPosition behavior. If the agent moves fast from greater distance the Stopping Distance is not respected. The agent is moved then exactly to the given position.
E.g. When I start from a distance like 8 m with a speed of 8 he ignores the distance, but when I start from like 4 m he stops at the given distance.

Secondly, when the agent reaches the border of the navmesh, it stops moving, sets velocity to zero, but the CantMove transition is never called.

Regards
Frank

Re: AgentMoveToPosition problem

Posted: 2023/12/14 10:41
by caitsithware
The Stopping Distance value is simply set to NavMeshAgent.stoppingDistance.
The CantMove transition will only transition when NavMeshAgent.SetDestination() returns false.

Both seem to be problems due to NavMeshAgent specifications.
Please refer to the AI Navigation package manual for details.

Re: AgentMoveToPosition problem

Posted: 2023/12/14 11:37
by frank_li
caitsithware wrote: 2023/12/14 10:41 The CantMove transition will only transition when NavMeshAgent.SetDestination() returns false.
I've seen that in your code, but this happens when the target position is outside the navmesh, so SetDestination should actually return false. I'll investigate this further.
Thanks for fast reply.

Re: AgentMoveToPosition problem

Posted: 2023/12/14 19:08
by frank_li
OK, it seems that if the destination target is outside the navmesh SetDestination moves the agent to the closest point it can reach, stops then and returns true. So in this case your CantMove will be never called and the agent is stalled.

Re: AgentMoveToPosition problem

Posted: 2023/12/15 00:17
by caitsithware
I see.
Currently, if it does not transition to CantMove even if it is outside the NavMesh range, it will transition to Done when the movement is completed.

As an improvement measure, we will consider adding an option to judge using NavMesh.SamplePosition.

Thank you for your report.