Hi @8trix , in a situation like this, it is typical to have an actor which acts as a manager for your enemy waves. In it’s simplest form (I will not go over basic optimizations like pre-spawning and reusing a pool of enemies, but you can research that independently) it will consist of an array of enemy actors, a float number to set your wave timer, and some algorithm which will help determine how many enemies of each type to spawn depending on which wave the player is on. It will also require functions to determine when to initiate a spawning sequence and the spawning sequence itself.
This actor will then be put in your level, and the level blueprint can activate it when on BeginPlay. I can’t blueprint the class for you at this time, but I can pseudo code it for you to use as reference.
class EnemyWaveManager
{
public:
// Class variables
// Seconds between waves
float WaveTimer = 10;
// Currently active enemies
TArray<AActor*> EnemyList;
// Count of the current wave the player is on
int Wave = 0;
// Number of enemies in each wave
int NumEnemies = 10;
// Checking for enemies in Tick
// (would be better to make an event on enemy death)
void Tick(float dt)
{
if(EnemyList.Length <= 0)
{
WaveComplete()
}
}
// Spawn wave function
void SpawnWave()
{
for (NumEnemies)
{
// Here is where you need an algorithm
// to figure out which type of enemy to spawn
MyEnemy* newEnemy = SpawnActorOfClass(MyEnemy);
EnemyList.Add(newEnemy)
}
}
// Spawns a new wave when timer is complete
void WaveComplete()
{
// Increment your wave
Wave = Wave + 1;
// Set your blueprint delay
Delay(WaveTimer);
// When the timer is complete spawn the next wave
SpawnWave();
}
// Removes the enemy from your list and destroys it
void EnemyKilled(AActor* Enemy)
{
// Make sure you remove the enemy first
EnemyList.Remove(Enemy);
// Destroy it
Enemy->BeginDestroy();
}
};
I know you said you were a beginner so sorry for the C++ markup… it’s just faster for me to answer that way; and this is just pseudo so it doesn’t compile in native. The basic idea is that when the level starts, you will call WaveComplete, which will start the process. Then after a delay, the first spawn will occur. When the player shoots an enemy, call the enemy killed function, which removes it from the list and destroys the enemy. As your manager checks to see if the list is empty, it will call wave complete, and the process cycles again.