2D Shooter: A Display for Waves
Objective: Create a display that shows the start and number of the wave.
Create a new UI text object in the Canvas object, and name is Wave_Display. Change the text to how you want it to look in game, and then create a new animation. For mine I changed the opacity to 0 in the first keyframe, raised it to 100 and then back to zero according to how I wanted it timed.
You can change the opacity of an object from the color swatch wheel.
Now let’s go to the UiManager script. We’ll want to create a variable to attach the object to.
Now let’s make a method that will update the wave number and start a coroutine to deactivate the object when the animation is over.
You can go to the spawn manager and tweak the wait time that delays enemy spawning until it times out better. For now, let’s go to the script for the Asteroid. We don’t want the display to show until after its destroyed.
Create a variable for the UIManager and get the script component.
Now let’s call the DisplayWaveNumber where the asteroid detects collision with the laser. We’ll want to pass on a variable representing the number 1, as shooting the asteroid will begin the first wave.
And now the display will work with what we have right now. We’ll be working on a more fleshed out wave system in the next article.