Diver

The diver's main purpose in the game is to take the player through the tutorial. In order to do that, he needs to be able to lead the player to a given destination. The leading behavior also needs to be versatile so that it still works even if the player has wandered off in the other direction.

The main idea behind my solution is to have the diver always stand between the player and the goal. The diver also prefers to be a certain distance away from the player. However, the diver cannot simply move to the exact location that I calculate. That location might be in midair or through a solid wall.

Instead of making the diver go to that calculated location, I ask him to go to the closest node on his navigation grid to that location. For getting the diver to the node, I let the engine's built-in pathfinding take over.

The diagram below represents the way I calculate the diver's ideal location, find the nearest node to that location, and send him to that node.