so i’m new to Unity and i got this error
NullReferenceException: Object reference not set to an instance of an object
and i can’t figure it out
This is my Enemy Script
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.10f)
{
GetNextWaypoint();
}
}
void GetNextWaypoint()
{
if (wavepointIndex >= Waypoints.points.Length - 1)
{
Destroy(gameObject);
return;
}
wavepointIndex++;
target = Waypoints.points[wavepointIndex];
}
This is my Waypoints script:
public static Transform[] points;
private int i;
void Awake ()
{
points = new Transform[transform.childCount];
for (int i = 0; i < points.Length; i++);
{
points *= transform.GetChild(i);*
}
}
}