Path goes through the walls

Hi guys, I’ve been playing around with this great AI library for a while because I’m making a 2d top down game, now I’m making a little prototype. The problem is when the units are chasing me when I move and a wall divides the player from the enemies; the agents even if they are blocked by the wall think there are no obstacles and make the path to the player pass thorugh the wall, like in these screenshots.



http://imgur.com/lVQohNz

At first I thought it was my flocking algorithm that messed with the velocity and physical stuff but I tried to disable it while there was only 1 unit in game and it still happened. I also modified the AI Lerp code to make it move a rigidbody, so maybe it’s the problem but I really don’t know… It is quite rare but when it happens it’s very annoying because sometimes the unit/s don’t recalculate the path and scroll along the wall until it finishes and finally follow the player correctly or they just stuck where they are and don’t move.
What should I change? Thank you in advance :grinning:!

Hi

Make sure the Seeker -> StartEndModifier -> End Point is set to ClosestOnNode or SnapToNode (depending on what you want). I would expect that now it is set to Original which will always set the last point of the path to the originally requested end point, even if that point could not be reached.

Hello, I tried to set the seeker values like you said but it didn’t work. The problem is not that the player walks in an unwalkable area but that the agent makes a wrong calculation and so thinks that the path has to go through the wall, what do you suggest to do?
Thank you very much for your time

Hi

Can you show a screenshot of how your graph looks together with a path?

Surely

Hm…
I don’t know. From the settings it seems like it should work.
How are you requesting the path?

To get the paths I attached a seeker and the AILerp script and set the target

(click on the image to see everything)

I found that when the enemy is stuck in the wall and I deactivate AILerp and immediately reactivate it the enemy recalculates the path and goes to the player correctly, but is there a more “elegant” way to solve this?
Thank you very much Aron

Hi

What is the ‘repathRate’ set to on the AILerp script?
You can call SearchPath on the AILerp component to force it to immediately recalculate the path.

Hi, I already solved it but I forgot ti write it ^_^’ I used a method similar to what you suggested. I saw that when the enemies were stuck if I disabled and immediately enabled the AILerp script the agent recalculated the path correctly, so I made the enemies check if they were stuck to a wall for more than an amount of time (for example 0.5s) and if they were, disabled and enable again AILerp. I think I’ll try what you said because it’s a more elegant way, the repath is 0.5. Thank you very much for your support

1 Like