Daily progress: Day 1, Thrusters.
Adding in Thrusters.
With GameDevHQ, we have been set a task to make this 2D space shooter. At this point in the journey, we have to research how to do a list of tasks to add to this game.
Adding in Thrusters:
We currently already have some thrusters in-game but they are purely visual, I started by adding in some functionality when the shift is held down is released.
Adding in a check for when the shift is held down was easy enough and adding in an extra variable to add to the speed of the player’s movement made it so when you hold down the shift button the player would move faster.
This was the easy part, now to change the size of the thruster when you hold down the shift key and revert when released. Doing a little research on how to do this, I came across “transform.localScale”. There was 1 downfall of using this though. When it scales the thruster down it, it will scale it down at the center, not the top which would make things a bit easier.
Add a reference for the thruster or in my case thrusters.
Next, we can change the localScale of those thrusters. Bigger when we press the shift down and Smaller when you release the shift key.
When I was working on the position of thrusters, they were acting very weirdly. Instead of being able to just move the thrusters to where they should be and put in those values.
Adding the characters transform.position to the thrusters will fix the not following the player but it will still have the too far away from the player distance.
Getting the thrusters to where they should be was kind of annoying. At first, I was trying to change the values to get it to the right place, lots of testing a value then changing it. In the end, though I worked out that the values had to be half of what they should be.
After that, I added them to their own method to clean up the update loop.
And the end result.
With that, this was how I implemented the thrusters both speed and visual, along with the problems I encountered. Next article I will be adding in Shield Strength. See you there!