Game Development Reference
In-Depth Information
Gizmos.DrawIcon() function to draw the icon image for each waypoint to
make it easier to edit. Then, we use Gizmos.DrawWireSphere() to draw
and calculate the area of each waypoint related to the radius of WaypointCon-
tainer .
We will see the error on the console that WaypointsContainer cannot be
found, but don't worry, we will add it in the next step.
3. Next, we will create the script in the same folder and name it WaypointsCon-
tainer . This script will have the basic function that checks for the direction,
distance, and draws the gizmos line between each waypoint. First, let's add the
following code:
// Unity JavaScript user:
#pragma strict
var showPath : boolean = true;
var isRandom : boolean = false;
var radius : float = 1.0f;
var waypoints : Waypoint[];
private var _lastWaypoint : Waypoint;
private var _nextIndex : int;
private var _wayIndex : int;
private var _wayLength : int;
private var _isHitRadius : boolean;
private var _direction : Vector3;
function Awake ()
{
showPath = false;
_isHitRadius = false;
_wayIndex = 0;
_nextIndex = _wayIndex + 1;
_wayLength = waypoints.Length;
_direction = Vector3.zero;
}
Search WWH ::




Custom Search