Hello guys, i don’t really know what’s wrong, when i start game i see over 999 errors where array index is out of range.
using UnityEngine;
using System.Collections;
public class AI : MonoBehaviour {
public Transform[ ] takas;
public float MoveSpeed = 4;
public float MaxDist = 10;
public float MinDist = 5;
public int i = 0;
// Use this for initialization
void Start () {
takas [0] = GameObject.Find (“1”).transform;
takas [1] = GameObject.Find (“2”).transform;
takas [2] = GameObject.Find (“3”).transform;
takas [3] = GameObject.Find (“4”).transform;
takas [4] = GameObject.Find (“5”).transform;
takas [5] = GameObject.Find (“6”).transform;
takas [6] = GameObject.Find (“7”).transform;
takas [7] = GameObject.Find (“8”).transform;
takas [8] = GameObject.Find (“9”).transform;
}
// Update is called once per frame
void Update () {
transform.LookAt(takas*);*
_ if(Vector3.Distance(transform.position, takas*.position) > 1)*_
_ transform.position += transform.forward * MoveSpeed * Time.deltaTime;_
_ if (Vector3.Distance (transform.position, takas*.position) <= 3) {
i++;
}
}
}*_