Chapter 7

Recipe: Waypoints Manager

7.1 Waypoint System

Both the racing game Motor Vehicle Doom and the shoot ’em up Interstellar Paranoids will need waypoints for the AI players. In Motor Vehicle Doom, we use waypoints for the AI and also for the main player for the following reasons:

  1. To check that the main player is heading in the right direction. The car controller code will track the player’s position on the track (based on which waypoint has been passed) and check its forward vector to make sure that it is facing the next waypoint along the track. If the player’s forward vector is not within a certain tolerance angle, the game will ...

Get C# Game Programming Cookbook for Unity 3D now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.