GameDev : how create the Triple Shot (Part II)!
This is the best part!
Now we have to create the LOGIC for our game. Because in Unity doesn’t exist!
The various concept of Life, Damage, Shooting, we have to create them from scratch!
Let’s try to solve this problem! We open up Player script, because the logic of FireLaser() is here, and Triple Shot is a part of shooting mechanics , right?
Now, we write Pseudo Code to understand how to do it
We have this in Update
Here we check if we press Space Bar.
we set every time the nextFire and we Instantiate Laser.
Now, a good logic can be :
We press SpaceBar, and we CHECK IF TRIPLE SHOT IS ACTIVE OR NO.
IF ACTIVE, TRIPLE SHOT, IF NOT, ONE LASER.
We starting with the check.
This is only the beginning, the real mechanics probably will be : I collect a power up, start a coroutine and we can use Triple Shot for 5 second, then back to normal.
But for now, focus ONLY on one little piece of problem.
The best way to make a simple check is with a BOOL.
So we create a bool
I make it public, just for testing.
We need a reference to TripleShot, just like the Laser
Then go back in FireLaser method, and set up If Statement
Now, if we test it
This works exactly how we expected.
If Triple Shot is not active we shot one Laser, but if we toggle it we fire Three Laser.
In the next articles we will implement the ability to collect some Power Up!!