using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class patrol : MonoBehaviour
{
public int currentIndex = 1;
public int maxIndex = 4;
public GameObject[ ]waypoints;
public float speed = 5f;
public int current;
public float wpRadius = 1f;
void Update()
{
if(Vector3.Distance(waypoints[current].transform.position, transform.position)< wpRadius)
{
current = current + 1;
}
if(current == maxIndex)
{
current = 1;
}
transform.position = Vector3.MoveTowards(transform.position, waypoints[current].transform.position, Time.deltaTime * speed);
}
}
Please provide the full error, and don’t use it as part of a poll.
Please put your code in code tags so that we can read it better, and provide the errors that you have so we can see what lines they refer to.
Help us to help you.
1 Like
Excellent news: I found your three errors!
error 1: you have a wrong letter in one place
error 2: you have a wrong number in another place
error 3: you have some wrong punctuation in yet a third place.
How to report problems productively in the Unity3D forums:
http://plbm.com/?p=220
Here are some notes on IndexOutOfRangeException and ArgumentOutOfRangeException:
http://plbm.com/?p=236
1 Like
Please read the rules and see posts above. Closed.