UPDATE: I’ve tried two methods to fix this,
1. Have the spawned enemy get the next waypoint from the enemy it spawned from.
2. Have the spawned enemy find the nearest waypoint.
The second method has it’s flaws, but I have no choice but to use it until I can somehow make the 1st method work.
Here’s most of the code for the 1st method:
void EnemyToSpawn (GameObject enemy, EnemyMovement _eM)
if (enemeyToSpawn != null)
for (int i = 0; i < enemy.Length; i++)
Instantiate(enemy[i], transform.position + (offset * i), transform.rotation);
WaveSpawner.EnemiesAlive += enemy.Length;
Debug.Log("Currently following: " + _eM.GetCurrentWaypoint());
// Problem detected: After instantiate, enemy follows first waypoint. Code a way for the new enemy to find next waypoint nearest to it. (Fixed? Kinda, see problem below)
// New problem: Finding next waypoint isn't perfect. Code a way to get the waypoint info from stronger enemy so the spawned enemy can follow that waypoint.
the eM is the EnemyMovement component gotten from the stronger enemy that the weaker enemy is spawned from. Sorry if this confuses you, I’m not good at explaining code to someone