Error null reference

Good day I have this problem:

my Project: https://gitlab.com/nio74/laserdefender

thys is my script EnemyPathing:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EnemyPathing : MonoBehaviour
{
    [SerializeField] WaveConfig waveConfig;
    [SerializeField] List<Transform> waypoints;
    [SerializeField] float moveSpeed = 2f;

    int waypointIndex = 0;
    // Start is called before the first frame update
    void Start()
    {
        waypoints = waveConfig.GetWaypoints();
        transform.position = waypoints[waypointIndex].transform.position;
    }

    // Update is called once per frame
    void Update()
    {
        Move();
    }

    private void Move()
    {
        if (waypointIndex <= waypoints.Count - 1)
        {
            var targhetPosition = waypoints[waypointIndex].transform.position;
            var movmentThisFrame = moveSpeed * Time.deltaTime;
            transform.position = Vector2.MoveTowards
                (transform.position, targhetPosition, movmentThisFrame);

            if (transform.position == targhetPosition)
            {
                waypointIndex++;
            }
        }
        else
        {
            Destroy(gameObject);
        }
    }
}```

Hi,

Welcome to our forum! :slight_smile:

NullReferenceException means that a reference (“link”) to an instance is missing. If you exposed a field in the Inspector, make sure that it’s not empty.

thank you it was just that

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms