Repath Rate, Easing & Raycast Modifier's Layer Mask

Hi there!

I just got the PRO version from the asset store and I’m really impressed with all the features and examples that I’ve been seeing on the forum and in the project files. There are however a few things which are probably pretty basic but I haven’t been able to figure out yet.


  • My first question is that with the option of Path Logging set to Normal (inside Astar Path) I keep getting these messages in my console that say “Path Completed : Computation Time 0.00 ms Searched Nodes 0 Path Length 1” when my agents are just standing still and doing nothing. Do these have an impact on performance at all? I’m building my game for mobile and I would rather my agents not look for paths if they’re just standing still.

  • My second question: I have the setup above on my agents (see screenshot) and it seems to do the job pretty well. I have an additional script which simply calls ai.destination = new Vector3(x, y, z); for whenever I have to move my agents. Now if I have my “Repath Rate” to say 2, it seems to pick up the new destination a bit slower than if the “repath rate” is set to 0.2. I understand that the script simply checks for a new destination every “Repath Rate” amount of seconds and moves the agent to that location if it finds a new one. Can I turn on and off this “Repath Rate”? So for example while it’s standing still, it doesn’t look for a path, but when I tell it to move somewhere, it does so immediately and until it reaches the destination it keeps updating the path in case obstacles appear in the way. This is I guess similar to what I asked in my first question, but a bit more complex.

  • My third question: There seems to be some “easing” effect to the agent’s moving while using the AI Path. For example if I tell the agent to move to one location, but then I send it to a new location, it sort of slows down from its current path, turns to the new destination and then moves towards it. While this whole “acceleration” adds a nice effect, I would like to tone it down a bit so the game feels more responsive. Any help on how I could achieve that?

  • Last question: From the documentation, my understanding is that if I have the Raycast Modifier script added to my agent and I enable Use Physics Raycasting and set my Layer Mask to “Hero” (as an example), if there are any colliders between my agent and the destination that have their Layer set to “Hero”, they’ll be treated as obstacles and the agent should go around them. Is that true? Am I missing something or is it likely that I’ve probably made an error on my end because my agent just goes through the “Hero” colliders instead of avoidign them.

Thank you very much in advance for your help!

I did a test of my own regarding the ray and mask. Whenever I send the ai.destionation the Vector3 of the location, I also cast a Physics.Linecast from the agent to the destination point, and check for a Collider on the same layer as the Raycast Modifier’s Layer Mask. My Physics.Linecast returns true meaning that it does find a Collider, however the agent still walks through it. So I’m guessing that I must be missing a component or a setting somewhere. Or is the Raycast Modifier’s Layer Mask not supposed to be used to avoid moving obstacles?

Please ignore my third question. I’ve figured that part out. Thanks!

  1. Yes it does have a performance impact, though not a very big one. If you want you can disable path recalculations by setting ai.canSearch = false.
  2. See 1. You might also be interested in the ai.SearchPath() method which will make the AI immediately start to search for a new path.
  3. The raycast modifier only simplifies an existing path as a post processing step, it doesn’t do any pathfinding itself. What it will do is to do raycast checks between points in the path to see if the path between those points can be simplified to a straight line.
1 Like

Thank you! What does the Layer Mask in the Raycast Modifier do then? In the documentation it says “Layer mask used for physics raycasting. All objects with layers that are included in this mask will be treated as obstacles.”

So it will do those raycast checks, but for that it needs a layer mask. If there is any obstacle in that layer mask between two points in the path, that part of the path will not be simplified to a straight line.

See also this gif from the documentation. Note the difference between the ‘Disabled’ and ‘Low Quality’ frames.
This particular gif uses the ‘Graph Raycasting’ mode however, not physics raycasting.

1 Like

Thank you very much!