Journal 151 — Unity Project Development, 2.5D Shooter

Objective: To add flash damage indicators to enemies, and checkpoint save after mid-level boss

In the previous article, I updated the final boss to add additional movement patterns when damaged. I also updated the style of the UI text. In this new article, I have added flash damage for when enemies are hit. I also added a checkpoint that will activate on restart if the player has made it to the mid-level boss.

Flash Damage

To add the flash damage, this came out fairly simple. I decided to use a copy of the enemy FBX model and modify the materials with a light color, then enable and disable the model when the enemy’s OnTriggerEnter event is triggered.

The basic enemy prefab looks like this. I added a copy of the 3D model and created a new material, and I played around with the color and texture settings.

I made a similar approach with the mid-level boss and final boss.

For the final boss, I found I needed to set the flashing model 1.05x the size of the base in order to see the effect.

In the C# scripts, I added a coroutine to show the flash damage by enabling and disabling the game object with a 0.1 second pause.

Now, here are the results.


For the checkpoint, this took a while through some trial and error to confirm it is working. Here is how I implemented this.

  • Created a DontDestroyOnLoad game object with a bool to track the mid-level boss was defeated so the checkpoint is true.
  • Store the current wave and score points in PlayerPrefs.
  • Modify the SpawnManager and UIManager and GameManager so the score and starting wave point can be recalled if the game is restarted to set the starting point after the mid-level boss level.

Here is the Checkpoint object script.

For the UI Manager, I added a couple functions to the Game Manager script to store the current wave, total number of waves, and the current score.

Here is the Game Manager functions for saving the score and waves.

In the mid-level boss script, when destroyed, I call a GameManager function to change the mid-level boss destroyed to true.

Here is the GameManager function that refers back to the CheckPointMaster object.

Finally, in the SpawnScriptable Object script, I changed the spawn start if the mid-level boss was destroyed, and pull the PlayerPrefs info to update the UI.

Through testing, I also found that the spawn level when restarting was always off by 1. This is because in PlayerPrefs I store is the UI display number (e.g., 1, 2, 3, etc.). However, the list of spawn waves starts at 0. So I updated the Start method to subtract 1 if the mid-level boss has been destroyed.

For testing, I have four levels, with the mid-level boss as Element 1 (Wave Number 2). So if I destroy the mid-level boss, then I should start at Element 2 (Wave Number 3).

Let’s see the results. After destroying the mid-level boss, the CheckPointMaster shows the checkpoint is reached. Also my coins are 1584, so if I die and restart, I should restart at Wave 3 with 1584 coins.

Here are the results.

Thank you for your time!

I plan to add a “CONTINUE” button on the main screen that will show if the checkpoint has been reached, but the overall functionality works.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store