Enemy Spawning

Hello all! I am now to the point where I need to setup the spawning of enemies for my game. There will only be one enemy at a time, and they will be spawned near the player, but out of the player’s view (left, right, behind). The game will randomly pick an enemy and spawn it. Should this be done in the Game Mode blueprint?

EDIT: Also, how should I keep track of the amount of objectives completed? In the Game Mode or what?

Never mind! I figured out how I wanted it. :smiley:

There you go then! However, that would be perfect to see your solution here so that we can discuss if it is the proper way of doing this or not. We would also be able to find a better way maybe.

Hey! I started by creating a array of ABGameplayTask (I have the base setup in C++) in the game mode blueprint. I created a function which is called when the game starts (BeginPlay) that gets all the tasks in the world, fills the array with them, and chooses a random one to start. In tick, I have a function called HandleTasks which loops through the Tasks array, gets the amount completed, and outputs it to an integer called TasksCompleted. I then created another integer called TasksNeededForLevel. In the for loop, after I check if a task is completed, I check to see if TasksCompleted is greater than or equal to TasksForNeededLevel (default: 10) multiplied by CurrentLevel (default: 1), and if so, I call a method called HandleLeveling. I created an array of objects in which I hold the types of enemies. In HandleLeveling, I increase CurrentLevel by one and spawn a random enemy out of the player’s view. Then finally once the for loop is completed, I reset TasksCompleted to 0.