How to find the Obsticale blocking the path

Ok so I`m working on a type of Tower defence game where enemys spawn then start walking towards 0,0,0
but the thing is the player can build stuff and can block the path to 0,0,0
so I just need to find out how could I go about finding what had blocked the path, but so far I havent been able to find out how to do that

1 Like

Have you tried raycasting?

When a raycast hits something it returns the instance it hit

This article is a tutorial/example about how to pathfind. It also goes over how to detect if something is blocking the path.

I was looking at that when I was looking for an awnser but didnt find anything about finding what blocked the path, could you tell me where it is in it becuse I can`t find it

If you look on the right hand side of the page there is a link called ‘Handling Blocked Paths’.

1 Like

I had seen that part and re-read it a couple of times (becuse i didnt understand it the first time) but it dosen`t tell any way of how to get the actual part blocking the path just about the waypoint that is getting blocked and about how to handle such a case if it happens

I don’t think that this method has the direct capability to do that, however it does give you the waypoint where it gets blocked, so you could use that position and find all parts within a certain area of that waypoint. You would then in turn be able to find the part causing the issue.

Its hacky but using this method is the only way I can see it working.

1 Like

I`ll try doing that method and get back to you if it fails somehow
EDIT: did a quick loop througth the Builds folder once the NPC got stuck and it managed to find the build blocking the way now I just gotta make it destroy it and such, Thank you RedDuck765

1 Like

I’d get the waypoints and fire a raycast from the first to the next waypoint