first time trying to use lists in C# I can add my objects in the inspector and my vehicle follows the waypoints but i keep getting the
ArgumentOutOfRangeException: Argument is out of range.
Parameter name: index
any help would be appreciated.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class WaypointSystem : MonoBehaviour {
public List<Transform>wayPoint = new List<Transform>() ;
public Transform currWayPoint;
private Transform myTransform;
public float moveSpeed=1;
public float rotationSpeed=1;
private int i = 0;
// Use this for initialization
void Start () {
myTransform = transform;
}
// Update is called once per frame
void Update ()
{
float distance = Vector3.Distance(wayPoint*.position, transform.position);*
_ Debug.DrawLine(wayPoint*.transform.position, myTransform.position);*_
* //Look at target_one*
* myTransform.rotation =Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation*
(wayPoint_.transform.position - myTransform.position),rotationSpeed Time.deltaTime);_
//Move Towards target_one*
_ myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;_
* if (distance<10)*
* {*
* i++;*
* Debug.Log(i);*
* }*
* }*
}