I’m stuck on the tower defence tutorial

Updated on June 28, 2017 in [A] Brackeys Courses
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
2 on June 27, 2017

I’m following the Tower Defence tutorial but I have run into a problem for a couple days that was halted all progress I’m making.

The error is as follows-

NullReferenceException: Object reference not set to an instance of an object
Enemy.Update () (at Assets/scripts/Enemy.cs:12)

and at the start of the program it gives this-

NullReferenceException: Object reference not set to an instance of an object
Enemy.Start () (at Assets/scripts/Enemy.cs:9)

I’ve been to Stack overflow(question marked as duplicate within 30 seconds) and Unity3d (Where I’ve gotten absolutey no reply.

The error isn’t in monodevlop, its actually on the Unity console and I’m stuck. Completely.


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.6f) {
void GetNextWaypoint(){
if (wavepointIndex >= waypoints.points.Length -1) {
target = waypoints.points[wavepointIndex];


using UnityEngine;
public class waypoints : MonoBehaviour {
public static Transform[] points;
void Awake(){
points = new Transform[transform.childCount];
for (int i = 0; i < points.Length; i++) {
points[i] = transform.GetChild (i);

I beg-please help me, Thanks

  • Liked by
1 on June 27, 2017

A NullReferenceException is just that, an exception for when you are referring to a null.

on June 28, 2017

I know that but how tf do i fix it?


Show more replies
  • Liked by