Dev Log 25: Added Rockets and fine tuning player boost
New Addition & Fix
The player will now be able to shoot rockets by picking up a rocket power up. Rockets will have a wide explosion that can take out multiple targets at once. It’ll detonate when it has made proximate contact with the enemy or after 1.3 seconds has passed.

Rocket Collider

The rocket’s fire rate is slightly slower than the triple shot power up so the collider was made wider to compensate. It’s really enjoyable to use and hard to miss any shots! its especially satisfying to see clusters of enemies get mowed down by one rocket!
Booster
The booster had an issue with scaling with speed. The logic simply did not adjust to the players increase in speed. therefore, the script would stop working after a certain speed level and the players boost would be uncontrollably fast. The boost gauge had a issue as well since the gauge was increased and decreased with a static number. So the boost gauge gradually become inaccurate relative to the player’s increased speed.
The issue was that the logic was somewhat hard coded. So all i needed to do is plug in my variables to all my conditional statements and made sure my equations were calculating with the changing speed variables.
Now I have something like this. Its looks the same, but its more robust.

It now scales with the players speed and will only boost the player 20% faster than its current speed. The boost gauge will also remain relative to the players change in speed.
Code Section
Ill try to be as brief as possible to show how this was assembled in code. Booster and power ups will not be covered since that’s been covered in a previous post . However, Ill break down the inner workings of the rocket behavior
link to Boost article : https://vixian.medium.com/day-20-boosting-the-player-681c4b1be6dc
link to Power Up article : https://vixian.medium.com/day-8-power-ups-and-scrolling-backrounds-32470a6c9952
Overview


Problem(Pseudo Code): When the player gets a rocket power up. The player will begin shooting rockets when space bar is inputted. When X amount of seconds has passed. The player’s projectile will return to normal.
The player script above calls the Fire() method whenever the player inputs space bar. It runs through a switch statement with a integer variable that is modified through picking up power ups. The variable acts as a identifier for each power up so that we may adjust the players behavior accordingly.
In this case, the number 2 is assigned to our rocket power up.
Laser Behavior Script (Rocket Behavior)
Problem(Pseudo Code): When the rocket is spawned. It’ll fly forward for 1.3 seconds and automatically detonate if not collided. When collided with an enemy, it’ll call the damage function to ALL collided enemies. Then spawn a explosion and destroy itself.
The main feature of an explosion is its area of effect characteristic. I utilized the physics2D.OverlapCapsuleAll() function to achieve the functionality of the explosion and instantiation for visual effect.
physics2D.OverlapCapsuleAll()
physics2D.OverlapCapsuleAll() is a function that is called and stored within a Collider2D variable. This function will check if another collider over laps a given space and return all collided objects to its array.
Its takes 4 essential parameters with 2 optional. The first four parameters consist of a Vector2 to designate our capsule in space, A vector2 to establish the size of the capsule, and A capsule direction which affects which direction the capsule will expand. Lastly, the angle of the capsule.
In addition to the four, A layer mask may be establish to check colliders on a specific layer and the Z axis of the capsule may be modified.

physics2D.OverlapCapsuleAll() is called when the rocket has collided with an game object with an enemy tag. The collided objects will be stored within the Collider2D variable named ,’EnemiesInRange’.
It will then run a for loop that’ll call the EDamage() method to each index within EnemiesInRange array. Once the loop is finished, an explosion will instantiate and the game object will destroy itself.
The same chunk of code is executed when the rocket has elapsed 1.3 seconds. This feature exist so that the player may damage future environmental objects.
Wrap up and Future plans

Its hard to show the rockets blasting multiple enemies at once. Its rare that they clump together and they spread out through the screen and fire very frequently.
So next ill be working on enemies and spawning. I will also be doing a complete overhaul of the provided game art from GameDevHQ.