Skip to content

Way Point Following

ConorZAM edited this page May 20, 2021 · 14 revisions

Way Point Following

The Way Point Tools Unity package provides the following:

  • Custom editor tools used to create paths of way points
  • Way point tracking script used to keep track of the current target way point
  • Kinematic Controller used to move an object towards a target way point
  • Look points used to point an object to face points of interest along the path

For a quick start guide click here

Creating Way Points

The WayPointManager script is used to create a path of way points in a scene. Way points are represented by the WayPoint class which contains information for the position of the way point and the position of the look point associated with the way point. A look point can be used to aim a camera while travelling between way points.

To use the way point Manager, attach the WayPointManager script to an empty game object in the scene. Name the game object something which can be used to identify the path you want to create - the way point Tracker will use the name you choose here to find the Manager during play mode. When dealing with only one path in your scene a name like "WayPoints" is suitable.

Inspector Name Highlight

To add a way point, click the Add WayPoint button. A new way point will be added to the scene, represented by a cube bearing the colour specified in the WayPoint Colour field (default is light green). Further way points will be added at an offset from the last way point in the path, the offset may be set using the New WayPoint Offset field.

Look Points

Generally, way points will suffice for a movement task, however, it can also be useful to specify a point to look at during travel. Every way point has a look point for exactly this. By default these points are hidden to reduce clutter in the scene, but can be shown by ticking the Show LookPoints field in the WayPointManager script. Look points are represented by spheres bearing the colour specified in the LookPoint Colour field (default is blue). Look points are connected by lines to their way point position.

Look Points

Tracking Way Points

The WayPointTracker script is used to keep track of which way point should be the target of a controller. A tolerance distance is used to check when the object has come close enough to the current target way point. When this distance is reached, the Tracker advances to the next way point.

Tracker Inspector

Other scripts may use the WayPointTracker by calling the GetCurrentWayPoint, GetCurrentLookPoint and GetCurrentWayPointData functions.

Following Way Points

We provide an example Kinematic Controller which moves the drone towards the Tracker's target position with constant speed. The Controller also uses the current look point as a target for the drone's orientation.

Controller Inspector