The NPC starts off at the yellow circle and the goal is for it to make all its way to the green circle.
The map consists of platforms formed by 4 circles of the same color (the yellow and green where colored differently to make it clear they are the starting point and the destination, respectively).
A platform can be rotated in angles of 90 degrees counter-clockwise.
The little black squares in the map are bridges that connect platforms. The NPC can walk across them to move from one platform to another.
The NPC can’t move from one circle to another (not event circles that are part of the same platform) unless there’s a bridge connecting them.
So the 2 only movements are: rotate a platform (adjacent circles of same color) and walk across a bridge.
The NavMesh is formed by all circles and bridges.
The challenge is what path the NPC has to take, given that the destination might not be right away reachable since platforms have to be rotated for the NPC to be able to move forward.
The way I thought (but couldn’t make it work yet) was to:
-
At the yellow circle Call “SetDestination” passing the position of the green circle.
-
Call CalculatePath:
- if the Pathstatus is “Complete”, then he can directly walk to destination.
- if the Pathstatus is “Partial” then I know that the platform has to be rotated. When platform is rotated, the NPC might start moving (if there’s a bridge to the adjacent platform) reaching eventually the destination (done), or getting stuck again (moment to rotate platform again).
- If NPC hasn’t reached destination, go back to 2)
Maybe I’m overcomplicating it.
Is this the right way to go? Is it more complicated than I think?