Hello, I have a script at which the end of an array, I want it to do nothing. Return; does not work. Instead, I get an error that the index is out of bounds. Since I do not want it to go back to 0, I want it to stop. Even making the array variable null doesn’t work.
if ( RelativeWaypointPosition.magnitude < 8 ) {
currentWaypoint ++;
//if ( currentWaypoint > waypoints.length ) {
if(currentWaypoint < 0 || currentWaypoint >= waypoints.length){
return;
yield WaitForSeconds(0.5);
waypointContainer = null;
Navigate = false;
inputSteer = 0;
FrontLeftWheel.steerAngle = FrontRightWheel.steerAngle = 0;
}
}