Hi, attached are the screenshots of the 2 scripts from this lesson. I can’t figure out why it won’t accept
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PathFinder : MonoBehaviour
{
EnemySpawner enemySpawner;
WaveConfigSO waveConfig;
List<Transform> waypoints;
int waypointIndex = 0;
void Awake()
{
enemySpawner = FindObjectOfType<EnemySpawner>();
}
void Start()
{
waveConfig = enemySpawner.GetCurrentWave();
waypoints = waveConfig.GetWayPoints();
transform.position = waypoints[waypointIndex].position;
}
void Update()
{
FollowPath();
}
void FollowPath()
{
if(waypointIndex < waypoints.Count)
{
Vector3 targetPosition = waypoints[waypointIndex].position;
float delta = waveConfig.GetMoveSpeed() * Time.deltaTime;
transform.position = Vector2.MoveTowards(transform.position, targetPosition, delta);
if(transform.position == targetPosition )
{
waypointIndex++;
}
}
else
{
Destroy(gameObject);
}
}
}
AND-------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemySpawner : MonoBehaviour
{
[SerializeField] WaveConfigSO currentWave;
void Start()
{
SpawnEnemies();
}
public WaveConfigSO CurrentWave()
{
return currentWave;
}
void SpawnEnemies()
{
Instantiate(currentWave.GetEnemyPrefab(0),
currentWave.GetStartingWayPoint().position, Quaternion.identity);
}
}