Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

NullReferenceException: Object reference not set to an instance of an object

$
0
0
I am trying to make an enemy movement script for my tower defence game but i keep getting this error and my enemy is not moving NullReferenceException: Object reference not set to an instance of an object EnemyMovement.Update () (at Assets/Scripts/EnemyMovement.cs:16) Here is my 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.4f) { GetNextWaypoint(); } } void GetNextWaypoint() { if (wavepointIndex >= Waypoints.points.Length -1) { Destroy (gameObject); return; } wavepointIndex++; target = Waypoints.points [wavepointIndex]; } If any one knows what the problem is your help is greatly appropriated thanks

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>