Game Development Reference
In-Depth Information
Creating the waypoint and gizmos
In the irst secion, we will create the
waypoint
script to place the waypoint for our AI
movement direcion, which can be edited in the editor. We will also learn how to use the
OnDrawGizmos()
funcion, which we have used in
Project 1
,
Creaing a Sprite and
Plaform Game
.
In this chapter, we will add the funcions below the
OnDrawGizmos()
funcion to show the
visual for our waypoint.
We use the
Gizmos.DrawIcon()
funcion to draw the icon image, see the direcion
line between two waypoints by using the
Gizmos.Draw
Line()
funcion, to draw the
line between two waypoints, and show the visual of the waypoint by using the
Gizmos.
DrawWireSphere()
funcion to draw the wire sphere at the posiion of the waypoint.
Prepare for Lift Off
First, we need to drag-and-drop the
Gizmos
folder, which is located outside the
Chapter6
folder, as shown in the following screenshot:
Why did we move the folder outside the
Chapter6
folder?
Take a look at this:
http://unity3d.com/support/documentation/
ScriptReference/Gizmos.DrawIcon.html
.
We see that the funcion takes two parameters: the irst is the posiion of the object
to draw the icon, and the second is the name of the icon image, which is
string
.
The documentaion says:
"The icon's path can be found in the
Assets/Gizmos
folder or in the
Unity.app/
Contents/Resources
folder."