A* Pathfinding Project integration, Wander task seems to stop working after being ran a second time

kingbdogz

New member
Hi there,

I'm new to this asset so there might be something obvious I'm not understanding. In my behavior tree (image below), I've noticed that if the AI begins to pursue the player then stop afterwards (I edited the Pursue task to have a max pursuit distance), it will return to the "Wander" task as it should. However, the AI just stands there forever and does nothing. It is all green and saying the task is running, but nothing seems to be happening. The first time the Wander task runs, it works perfectly fine and will be seen wandering around.

Any tips?

1624756215391.png
 

Justin

Administrator
Staff member
The Wander task will always return a status of running so that's why it's in the current state. Your Can See Object task is reevaluating using a lower priority conditional abort and as soon as that returns success the wander task will stop running.
 

kingbdogz

New member
If I'm understanding you correctly, it's considered "still running" but technically has been ended? If that's the case, how do I get it to restart once Can See Object returns failure?
 

Justin

Administrator
Staff member
Can See Object returned failure so the selector above then runs the Wander task. The Wander task will keep running until can see returns success. If you want to flip the logic you can add an inverter on top of can see.
 

kingbdogz

New member
I think there might be a misunderstanding, either on my end or otherwise. The problem I'm facing is that Wander is running (which is what I'm intending) but the AI agent won't actually move around. At least, that's what happens when Wander is running a second time after Can See Object has returned success and then failure again.

The first time Wander runs, the agent is running around fine, taking pauses, etc. It's just that second time after the Selector reevaluates that it seems to stop functioning.
 

Justin

Administrator
Staff member
Ah, that is different from what I was understanding. To get started does wander work correctly in the demo scene? Also, is a path being set?
 

kingbdogz

New member
Yes it does seem to work fine in the demo scene. I think the difference between the demo scene and mine is that the demo scene doesn't have another task (Can See Object) potentially interrupting it. My Wander task works fine up until Can See Object interrupts it, then stops (when the target is no longer in sight). Even though the Wander task is green on its second run, it stops working.

1625241481048.png
It seems it has a path but isn't doing anything to actually move to it. Although it seems it might be trying to path outside of the grid graph. I don't think that's the problem though since I've seen it stop moving when not close to the edge.
 

kingbdogz

New member
OK I figured it out, sort of. I think this might be a bug somewhere. Looking at the Wander task code, it seems that it only sets a new path/target if the agent either has no current path, or has arrived at their destination. The problem seems to be that for whatever reason, the Pursue task is ending while keeping a path active within the agent (even if it doesn't actually pursue that path).

I was able to "fix" the problem by adding `agent.SetPath(null)` in Wander.OnStart(). This doesn't feel like the correct fix though, and also makes me wonder why even though a path is technically active within the agent while Wander starts/is running, it doesn't seem to be following it.

Any suggestions of what might actually be going wrong here? Am I doing something wrong on my end or do you think it's a bug for the pack that warrants a patch of the A* movement pack?
 

Justin

Administrator
Staff member
I'll try a similar setup as you and if I am hitting the same problem will update the task to set the path to null within OnEnd. I'll let you know after I get a chance to test it.
 

kingbdogz

New member
Thank you! Let me know if I can provide anything to help. If you do get it working without a fix, I'd be curious if you could send over a test scene to see what I'm doing wrong with my setup.
 
Top