If you’re working on an Arcade type of game, you will need a Score System, so in this tutorial we will create one from scratch and add it to the template, this can be considered Part II of the Mobile Tutorial, but it’s also its own thing.
First create a new Blueprint Actor and call it “Enemy_Spawner” or something along those lines, add only a box component to it, to use as a volume for where the enemies will spawn.
After that create a new function for every type of enemy that should be spawned.
This example is for the soldier type, but others have identical logic, only the class is different.
After that, create a Custom Event and recreate this Blueprint.
Now let’s move on to the GameMode, create a new Int variable (Score) and add this to Begin Play. What this will do is call the Custom Event from the Enemy_Spawner and spawn a random enemy every 2 seconds.
Now (still in GameMode) create a new function and call it AddScore, nothing too complicated, just an input integer and some basic math to 1+1 it and set the result.
Now open any enemy and add this to its BeginPlay
And this to when its health reaches 0
Now let’s move on to the HUD widget, add the GameMode reference when it’s constructed, same way like with the enemy, Character should already be there.
Now add a new text and create a binding, this will display the current Score on the HUD.
GAME OVER WIDGET
And last but not least, do pretty much the same on the GameOver widget.
When the player health reaches 0, instead of the default respawn logic, simply create that new game over widget and add it to the viewport
If you followed all steps from this tutorial and the mobile tutorial, this should be the result, minus the assets of course..
As you can see the enemies attack you in random patterns, score gets added everytime you kill an enemy, on game over, it shows the total score.
You can expand this system to include other things as well.
Timer (GameMode), StartCounting on BeginPlay and add a text to the HUD to show it.
Making the enemy sense the player from a huge distance, so that it actively tries to reach the player, even if there are walls separating them.
Add the Enemy_Spawner in more than one location in the level.
NOTE: You can also download a slightly different (newer) version here. Wave Based Game Mode example, extract like it is in the zip file, open the level that comes with it, press play.