I am currently working on a game that requires me to have a gameObject follow a set path from one waypoint to another. However While I run the program the moment my script causes Unity to lock up. Here is my current script.
var roll : int = 5;
var CurrentWaypoint : GameObject;
var nextWaypoint : GameObject;
var change : int = 1;
var theWayPoints = new Array ("WayPoint1.1","WayPoint1.2","WayPoint1.3","WayPoint1.4","WayPoint1.5","WayPoint1.6","WayPoint1.7","WayPoint1.8","WayPoint1.9","WayPoint1.10","WayPoint1.11","WayPointF");
var i = 0;
function Update(){
transform.Translate(Vector3(0,0,roll)* Time.deltaTime);
PathOne();
transform.LookAt(CurrentWaypoint.transform);
}
function PathOne(){
while(i<theWayPoints.length)
{
if (Vector3.Distance (transform.position , CurrentWaypoint.transform.position) < change)
{
CurrentWaypoint = nextWaypoint;
if (CurrentWaypoint == GameObject(theWayPoints*))*
*{*
*i++;*
_nextWaypoint = GameObject(theWayPoints*);*_
_*}*_
_*else*_
_*{*_
_*Destroy(gameObject);*_
_*}*_
_*}*_
_*}*_
_*}*_
_*```*_
_*<p>I have having it look for tags and just named gameobjects. But no luck. Any idea on what I did wrong?</p>*_