Instead of change the equation within the move method, would there be any issues that arise by moving the variable initalization to the Start function by calling the waveConfig.GetMoveSpeed? my solution below:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyPathing : MonoBehaviour
{
[SerializeField] List waypoints;
[SerializeField] WaveConfig waveConfig;
int waypointIndex = 0;
float moveSpeed;
// Start is called before the first frame update
void Start()
{
waypoints = waveConfig.GetWaypoints();
transform.position = waypoints[waypointIndex].transform.position;
moveSpeed = waveConfig.GetMoveSpeed();
}
// Update is called once per frame
void Update()
{
Move();
}
private void Move()
{
if (waypointIndex <= waypoints.Count - 1)
{
var targetPos = waypoints[waypointIndex].transform.position;
var movementThisFrame = moveSpeed * Time.deltaTime;
transform.position = Vector2.MoveTowards(transform.position, targetPos, movementThisFrame);
if (transform.position == targetPos)
{
waypointIndex++;
}
}
else
{
Destroy(gameObject);
}
}
}