AiPath.reachedDestination always false

I am using the Behavior Designer asset and I’m trying to implement random walking / wandering movement.

Here is what my tree looks like:
Screenshot_1

I want to select a random position, and check with AiPath.reachedDestination if agent has finished walking, to mark the task as completed and go to the
block which waits a bit and then restarts the wandering process.

Here’s the code:

The problem is that when I use seeker.StartPath(), it looks like the AiPath destination is never set (I tried logging it and it says it’s infinity), therefore AiPath.reachedDestination always returns false, which results in an endless loop of waiting.

However, setting AiPath.destination directly works as intended, but I’m pretty sure I’m always supposed to use the Seeker component so it can easily handle all the modifiers.

What am I doing wrong?

Hi

The Seeker is mostly for when you are writing your own movement script. The AIPath script will automatically calculate its path using the Seeker when you supply it with a destination.

So just set ai.destination = whatever (and optionally call ai.SearchPath() if you want to force it to update its path immediately) and then it will work.

1 Like

Hi!

Thank you, this seems to work.

EDIT: the repath rate kept checking every 0.5s and that’s why this is happening. I will manually disable and enable canSearch because I know exactly if and when agents should be repathing, so this issue no longer occurs. :slight_smile:

I tried it before but the reason I thought it was the wrong way to do it is because AFTER setting the destination I am constantly getting these messages in the console:

Screenshot_1

This is when the MoveTo behavior isn’t running and the Wait task is active.

Why is it still logging what I’m assuming to be constant path calculations even when I set the destination? Do I have to “unset” the destination to make it stop calculating the path?

Is this because of the “repath rate” in the AIPath script?

1 Like