Game Development Reference
In-Depth Information
// C# user:
using UnityEngine;
using System.Collections;
public class WaypointsContainer : MonoBehaviour
{
public bool showPath = true;
public bool isRandom = false;
public float radius = 1.0f;
public Waypoint[] waypoints;
Waypoint _lastWaypoint;
int _nextIndex;
int _wayIndex;
int _wayLength;
bool _isHitRadius;
Vector3 _direction;
void Awake ()
{
showPath = false;
_isHitRadius = false;
_wayIndex = 0;
_nextIndex = _wayIndex + 1;
_wayLength = waypoints.Length;
_direction = Vector3.zero;
}
}
4. Next, we will add another function that basically checks if the enemy is away
from the next waypoint or not. We will use this function to make sure that the en-
emy isn't going too far from the area, which will give our enemy more character-
istics. Let's add the following code after the Awake() function:
// Unity JavaScript user:
function AwayFromWaypoint ( position : Vector3,
Search WWH ::




Custom Search