O'Reilly logo

Unity 4 Game Development HOTSHOT by Jate Wittayabundit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating the Waypoint and WaypointsContainer scripts

In the first section, we will create the Waypoint and WaypointsContainer script to place the waypoint for our AI movement direction, which can be edited in the editor.

First, we will create the Waypoint script and use the Gizmos object to draw an image icon (Gizmos.DrawIcon()) and the wire sphere (Gizmos.DrawWireSphere()) by putting it in OnDrawGizmos(). Both functions are used to draw the image icon and the radius of waypoint, which is used to display the position of waypoint and the radius that the character should start turning to the next waypoint.

Then, we will create WaypointsContainer that will contain all necessary functions to get the direction of the current waypoint to the next one. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required