Recently I’ve been trying to make a pathfinding script, and I succeeded, however, I’ve discovered a problem.
The generated path can’t detect for walls blocking it. So, I tried to see if a ray could reach the point if so, then use that point. So far, this is not working at all I’ve been trying to fix this since ysterday. I’ve abandoned my attempt to use raycasting as it would only crash my studio upon running. Any ideas on how to do this?
What part of your script is not working? If its the rays make sure that the ray is long enough to reach the position of the waypoint. It would also help if we saw the code your working with for reference. Hope this helps.
NOTE: Waypoints are usually easy to set up however they don’t result in very realistic movement paths
You could then build a table showing which ones connect to each other like the one above and move the NPC by using some kind of searching algorithm of your choice.
You could also divide the map up into a grid and mark blocked sections of the map. You could then use the A* algorithm to search through this or yet again any algorithm of your choice.
This is more like your current solution however this method stores the data about obstacles rather than detecting them in real time.
I’ve got the same problem as well, but the best alternative that I found by myself is to use a RunService loop and just call a function that creates a new path and re-ComputeAsync() it. It will create a new path constantly and create new waypoints. Hope this help.