How to best control agent navigation rules and radius

Hello All,

I am attempting to move to handling the agent radius and navigation a bit more granular. Can you point me to documentation on how we can control the radius of the agents?

What I am occasionally running into is the following

  1. Agents walking too close to walls (i.e. edges of the grid)
  2. Sometimes agents get stuck and can’t autocorrect

I am grateful for any insight into ways to handle the above two issues.

Thanks!

Hi

This can be controlled by a lot of things.
Primarily there are three different categories:

  • How close the graph border is to the obstacles
    • This is determined by the ‘collision testing diameter’ as well as the erosion setting on grid graphs.
  • How much the path is smoothed
    • If you are using the simple smooth modifier, you may want to reduce the smoothing
  • How closely the path is followed

On the AIPath script you can also enable the ‘constrain to inside graph’ checkbox which will prevent it from moving outside the graph (for a small performance penalty).

It’s hard to say anything about (2) without knowing more about the specific cases where they get stuck though.

Thanks Aron,

I will try these suggestions out tomorrow. I really appreciate your help again!

Thanks again Aron, is there a velocity value that I can always check to make sure that if the agent hasn’t reached the destination and the velocity is below a certain threshold, we can prevent the agent getting “stuck” or implement a workaround to get the agent from being stuck?

Thanks in advance!

Hi

Yes there is.

// IAstarAI is an interface that all movement scripts (e.g. AIPath) implements, you can use GetComponent<AIPath> instead if you want
var ai = GetComponent<IAstarAI>();

var v = ai.velocity;
var v2 = ai.desiredVelocity;

See also https://arongranberg.com/astar/docs/iastarai.html