Unbroken v0.3.106 - Game Over?
Dev Diary: Update 3
“Hey, partner!
This is Adam from Delta Squad. In the past days, mission control observed that some pilots preferred avoiding direct enemy contact. A surefire way to make yourself known as a coward right from the get-go, huh? I thought they brought the crème de la crème, but it seems like not everybody is made for this. As a response, Management announced a new incentives program. Sounds like the rewards for actually taking down an alien ship are quite profitable. Just saying …
By the way, our ships received a few upgrades. Digital sight enhancers were installed. You will see, it is even more fun to destroy the alien ships, now that you can clearly see ‘em blow up in a satisfying explosion. Also, the ship hull was strengthened. We can now tank more than a single hit. But don’t get overly confident out there. We are not invulnerable. Every mistake could be your last, and then it’s Game Over!”
Adam Pierce, Delta Squad Pilot, Unbroken Organization
Release Notes
Gameplay
- enemy ships are now spawned in multiple waves
Balancing
- Player Ship can take more than 1 hit
Visual Effects
- explosion animations for ships and projectiles
UI
- Basic HUD, displaying score and player ship HP
- Game Over screen
- “Mission failed” screen, when the player ship is destroyed
- “Mission succeeded” screen, when all enemy ships were destroyed
Tech Talk
Building the Heads-Up Display (HUD)
When building UI elements like a HUD or a popup menu, we usually want these elements to be rendered on top of everything else in the Scene. Nothing should be obstructed by anything from within the game world. The player should be able to see all relevant information all the time.
For that purpose, Unity provides the Canvas. Using the render mode “Screen Space - Overlay”, the Canvas does exactly what we need, without us dealing with the details of rendering order or sorting layers.
Just like anything else in Unity, the Canvas is a GameObject that can be added to your Scene. By adding new UI elments (like Images, TextFields, Buttons, …) to the Canvas GameObject, we can build up our HUD pretty much like we would do with most other UI builders. We add two text fields called Score and HP, and two more text fields for their respective values, which we initialize with the value 0.
Finally, to make sure, the UI elements appear at the correct spot even for different screen sizes and resolutions, we align them relative to the screen edges using Unity’s anchoring system.
When we now start the game, we find our HUD elements lined up nicely. Also objects from the game world, like the alien ship at the top right, do not obstruct our HUD.
But as you can see, the values are all zeros, which does not reflect the actual game state. So, now we need a script (let’s call it UIManager) that:
- receives the references to both text fields that require live updates during the game
- provides methods that update the Score and HP displays, which can be called by other scripts whenever the values change because of some actions taking place in the game
Building Game Over screens
With the score and HP being displayed in the HUD, we now give the player a sense of how well he is doing in the game. But for now there is no real end to the game. When the player survived the last wave or is killed, the game just runs along as if nothing happened. Instead, there should be a Game Over screen with a success or failure message. In both cases, we want the player to be able to restart the game with a single button click.
So let’s extend our Canvas by adding
- a text field “Mission Completed!” (in green font)
- a text field “Mission Failed!” (in red font)
- a button “Restart”
All of the new elements are already displayed at game start. We can simply deactivate them. Then we extend our UIManager script with additional references to the new UI elements and add two new methods that activate the correct UI elements as soon as the game is over.
Now, when we kill the last wave, the “Mission Completed” screen appears.
Explosions
Aliens just disappearing when being hit is boring. Let’s make them explode! Therefore, we can use the Unity Particle system. Since particles are an extremely complex topic, I don’t really want to deal with that in my first project. But Gustav Hagerling already created a great particle effect for an explosion and provided it as a free asset in the Unity Asset store (see: Explosive Realistic VFX Texture Free).
Let’s use that asset as a template and create two variants:
- a big explosion (for ships)
- a small explosion (for projectiles)
Next, we add an explosion particle parameter to our ShipClass and ProjectileClass.
As a result, we will be able to easily switch out different explosions for ships and projectiles later on. This will require no code change. Instead we can just drag in new explosion assets in the Unity inspector.
Get Unbroken - Mankind United
Unbroken - Mankind United
Defend Humanity against the Alien Invasion
Status | In development |
Author | Tobias Mielke |
Genre | Action |
Tags | 2D, Singleplayer, Space, Unity |
Languages | English |
More posts
- Unbroken v0.7.264 - Modular Ship BuildingSep 06, 2022
- Unbroken v0.6.187 - Boss FightAug 14, 2022
- Unbroken v0.5.162 - Ship ModulesAug 06, 2022
- Unbroken v0.4.136 - Sounds GoodAug 05, 2022
- Unbroken v0.2.74 - The Path to SuccessAug 03, 2022
- Unbroken v0.1.32 - First ContactAug 03, 2022
- Unbroken v0.1.16 - Endless SpaceAug 03, 2022
Leave a comment
Log in with itch.io to leave a comment.