- A* version: 4.2.15 (2020-03-30)
- Unity version: 2022.3.10f1
Is there a way to get the tag of the node the agent is currently on?
I’m wanting to change the speed of the NPC when it’s walking on a node of a certain tag. So that when NPCs are running through a danger zone (the green tagged nodes around the swinging axes), they speed up to get through the danger zone quickly.
I could also use this to make NPCs walk more slowly through other tags, i.e. wading through a swamp.
I could run AstarPath.active.GetNearest(position, NNConstraint.Default) and get the node’s tag every tick but I figure this would be very inefficient, especially for upwards of 20 NPCs in a scene
Hi
If you are using the FollowerEntity movement script, you can use ai.currentNode.Tag. But for the other movement scripts, you have to call GetNearest. For only 20 agents, it’s actually not that bad.
Thanks for the reply 
You’re correct, I tested it on my most NPC heavy level, running it every Update() on every NPC resulted in an FPS decrease from ~122 fps to ~115fps
Still though that “Expensive method invocation” warning in Rider scares me 
Do you think switching to the FollowerEntity script would have any other notable performance increases compared to using AIPath and GetNearest()?
(also is it worth updating, since I’m on an older version 4.2.15?)
The follower entity movement script is generally more performant than aipath. Especially at higher agent counts.