Journal 152 — Unity Project Development, 2.5D Shooter
Objective: Add another player weapon and modify enemy power up behavior
In this article, I go over how I added one more player weapon power up. I will also go over how the enemy power up drops work.
Player Weapon
I decided to add another triple shot but change the look and make them do double damage.
To start, I modified the sprites in the prefab. I also made a new tag so I can check for collisions with this more powerful attack.
I kept the same components so I can reuse the same bullet scripts. In the enemy C# script, under the OnTriggerEnter function, I check for this new projectile, and I call the hit tracker twice.
Here it is in action.
Similar to the other weapon levels that were added previously, I updated the Player script with a new weapon level, a new prefab that would spawn on the Player, and a new sprite that would show on the UI Canvas.
Power Up Spawn
For the final version of the enemies, I want to spawn a power up on random enemies that are flashing. For a flashing enemy, I used the game object for flash damage. I tried some coroutines and update methods to make a repeating enemy flash, but it did not look consistent. I found that InvokeRepeating and CancelInvoke worked well. So I added a random number check or the enemy when spawned, and if that enemy was designated to drop power ups, then I would enable and disable the flashing game object.
In the Enemy C# script, I set the InvokeRepeating function, and then in the EnemyDeath function, I CancelInvoke.
Here it is in action.
Thank you for your time!
I want to look again at all the audio sounds and behavior, use the Unity Profiler to do some testing, and look at all the code organization before posting.