I have an actor that I have that uses FPtLS along with some custom code to choose a path through a randomly generated maze and in a few instances of this maze, that I am able to recreate every time, when the actor uses FPtLS to find the correct route through the maze, it creates a very strange path and I don’t know why. I wouldn’t mind if it weren’t breaking how the actor moves in the maze with locations snapped to a grid.
Here is the intersection of the maze that’s causing trouble. The red is the dynamic navmesh for the actor. The green sphere is the starting position of the actor.
The loop the actor is supposed to do is check what’s surrounding it (wall or empty), make a decision where to go, and then move. Most of the time it’s a random decision where to go, but there is code to force the actor to go the correct direction.
What’s supposed to happen, is that the actor is supposed to see that it can only go forward, move 100 units (the grid size) and check what directions are available to move. Currently, I am forcing the actor to always make the right choice and move down the correct path. In this example, the actor will move to the left, use FPtLS to see that the path is up and move to the Location at Distance (100) Along Spline
But this is the representation of the spline that’s actually created in this instance of the maze (white) when the actor makes it’s move out of the starting position. For some reason, the spline goes back to the world origin (which is the starting position if that matters) and then moves in the proper direction. The problem is that since I’m only using the location that’s 100 unites along the spline and then snapping it to a grid, that means the actor goes back to the starting position.
Then the loop starts back to checking what’s surrounding the actor. Since it’s a dead end, it’ll turn around and fall into this endless loop of going back and forth until the Move To Location or Actor fails.
Do any of you guys know why the FPtLS creates such an odd path and why it’s only in 1 in every 20 or so mazes I generate? It’s an uncommon error, but I would still like to fix it if possible instead of coming up with workarounds like forcing it to go in a random direction if it loops enough times (I have that in place right now. It works but it’s not pretty)