When one firepower isn’t enough!
Having more options is always a good thing. Currently, we have 2 different ways to fire, a single shot and a triple shot. This is all good and well but getting a new way to kill all the enemies would be nice.
Now the fun begins, starting out I had many ideas for this and some of them I may still act on.
Making the prefabs:
Started by adding a container for all the lasers, then drag a laser in as a child of that. Duplicating the starting laser while working around, first at 90 degrees, then 45 degrees then finally 22.5 degrees. Since we duplicated the starting laser, they all should have the 2D rigid body, 2D Box collider, and the laser script. Save the container as a new PreFab and this part is done.
After finding an image I liked and after a couple of touch-ups,
Dragging this into the hierarchy and adding the usual suspects, Power up Script (Change ID to 5, drop in the Clip), 2D Rigidbody (Set gravity scale to 0), and 2D Box Collider (mark as Trigger) and you’re done!… making the prefabs.
This one should be super quick. We will need somewhere to store the prefab, and a bool to be able to tell if we have the new firepower or not.
Next will be being able to actually use the new firepower, it will look a little like the triple shot. In the Shoot method:
All that’s left is a method and cooldown for getting and taking away the new firepower.
This one is super crazy short lol, 3 lines short. All that is needed was to add in a new case for the new firepower.
Back to the inspector now where we can finish it all off.
Drop in the prefab for the new firepower,
Drop in the prefab for the pickup for the new Firepower.
And done! As always test to see things are working and See you in the next one!