How to completely cancel a path?

I’m using object pooling on agents with the RichAI component on a recast graph and when they respawn they seem to still have their old path that they try to complete.

I was using RichAI ai.SetPath(null); but that doesn’t seem to be working.

How can I completely cancel a path?

Hi

Just making sure the objects are disabled when they enter the pool should do it. You may also want to set ai.destination = new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); unless you set a new destination immediately when they spawn.

When you say “Make sure the objects are disabled” you mean the game objects? If so, I’m doing that.

I’ll experiment with destination and report back, thanks!

The agent will keep its destination when it is disabled. So likely what happens is that immediately when it gets activated again, it will quickly calculate a path to its previous destination and start following that.

Ok I think that fixed it!

I set the ai.destination = Vector3.positiveInfinity and now when they respawn they are standing still before picking a new location as expected.

Thanks for the help!

1 Like