Well on July 21st I ran into this problem & in attempts to solve it I had restarted the Laser Defender class twice already. Now I am stuck at the same exact place I was on July 21. Let me show you.
,…
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyPathing : MonoBehaviour
{
[SerializeField] WaveConfig waveConfig;
List waypoints;
[SerializeField] float moveSpeed = 2f;
int waypointIndex = 0;
void Start()
{
waypoints = waveConfig.GetWaypoints();
transform.position = waypoints[waypointIndex].transform.position;
}
void Update()
{
//EnemyPathing.Update () (at Assets/Scripts/EnemyPathing.cs:20) The Move(); is error
Move();
}
private void Move()
{
{
// NullReferenceException: Object reference not set to an instance of an object
// EnemyPathing.Move()(at Assets / Scripts / EnemyPathing.cs:28) The next line is error
var targetPosition = waypoints[waypointIndex].transform.position;
var movementThisFrame = moveSpeed * Time.deltaTime;
transform.position = Vector2.MoveTowards(transform.position, targetPosition, movementThisFrame);
if (transform.position == targetPosition)
{
waypointIndex++;
Debug.Log("Value of waypointIndex: " + waypointIndex);
Debug.Log("Position of targetPosition: " + targetPosition);
}
else
{
Destroy(gameObject);
}}
}
}
,…
For anyone who wants to see what I’ve already done & how I got here again.