The Problem: How to create a Golf-like shooting system based on 4 parameters? (Golf, Power Meter, Perfect Shot, Accuracy Meter, Rotating View)
To create this launching logic, I had to create different stages for every shot taken. This if statement will start the shooting phase when the player presses space bar. This will stop the player's ability to rotate the ship. It will also activate the Power meter.
This stage will require the player to press the space bar to stop the pointer position on the power meter. When the player presses the space bar it will stop the pointer animation and will check what is the position of the pointer, based on that position the amount of power is saved into a variable. This if statement will start the 3rd stage.
This stage is similar to the 2nd stage, but instead of getting power by pressing space at the accurate time the player will get the accuracy of the shot based on the position of the pointer. The accuracy of the shot is based on where the player was aiming the shot before starting the launching logic sequence, if he hits it perfectly (the middle of the accuracy bar) the shot will be launched at the desired direction. This will take the player to the final stage.
The final stage gathers all the variables needed: the power from stage 2, the accuracy from stage 3, and the direction of where the ship is being aimed at. Those three things are added into a formula that will change the direction and power the ship will be launched at, also adding the ship's power (every ship has specific strengths), and the thruster power. The force applied to the ship is the output of the formula.
The Problem: How to create distinct abilities for each character/ship? (Abilities, Bomb, Defensive, Offensive)
Every ability in the game can only be used when the ship is in the air.
The first ability created was deviate course which was based on the amount of fuel the ship had. While the A or D keys were being pressed down the fuel of the ship would also go down and move the ship towards that direction. I basically added a force towards that direction.
The second ability created was thruster jump which could only be used once per turn. When the Space bar is pressed the ship would thrust itself upwards covering more ground. A force upward was applied to the ship.
The third ability created was instant stop which could only be used once per turn. The ship would basically stop its velocity and would only be affected by gravity (fall down). When the Space bar is pressed the ship would stop moving. Velocity and Angular Velocity became zero on button pressed.
The fourth ability created was platform creator which could only be used once per turn. The ship would stop and create a platform under itself. When the Space bar is pressed the platform is created and the velocity of the ship becomes zero. The idea is that the player can save himself from getting launched out of bounds.
The fifth ability created was called the ghost ship which could only be used once per turn like the other ones. The ship would phase through objects in the course. When the Space bar is pressed the ghost fuel starts getting used, while causing the ship to go into phase mode. If the button is pressed again the ship stops phasing and the fuel stops being used.
The Offensive Ability
This ability can be used once per turn, by every player. This basically helps the player push other player's ships off of the course. I created a prefab of a bomb and when the player pressed C the bomb would be spawned underneath the ship and when it collided with the ground the bomb would create a collider radius that if collided with it would push ships away based on the games physics.
The Problem: How to create a system that will predict the trajectory of a perfect shot? (Perfect Shot, Predicting Algorithm, Trajectory, System)
For this I created a prefab of the ship being launched and created it when the shift button was pressed. This ship had all the properties the actual ship had, but the only addition was a line renderer that would stay on until the object is destroyed.
Lastly I used a time asset so I could speed the object up (time-wise) which caused the object to get to its destination almost instantly. When the object reached the floor it would stop moving. If the player rotated the ship or changed thrusters the object was destroyed. Lastly I used the perfect power and the perfect accuracy to figure out the force and direction for a perfect shot.