Hello I need help for this piece of code for a mate can anyone help for line 17 it’s spamming the same error over and over again in console
using UnityEngine;
public class Enemy : MonoBehaviour{
public float speed = 10f;
private Transform target;
private int wavepointIndex = 0;
void start()
{
target = Waypoints.points[0];
}
void Update()
{
Vector3 dir = target.position - transform.position;
transform.Translate(dir.normalized * speed * Time.deltaTime, Space.World);
if (Vector3.Distance(transform.position, target.position) <= 0.2f)
{
GetNextWaypoint();
}
}
void GetNextWaypoint()
{
if (wavepointIndex >= Waypoints.points.Length - 1)
{
Destroy(gameObject);
return;
}
wavepointIndex++;
target = Waypoints.points[wavepointIndex];
}
}