Daily progress: Day 1, Thrusters.

Adding in Thrusters.

Rose Owen
Nerd For Tech

--

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 is placed in the Update method since we are checking for player Input.
This one comes from the Player Movement method we made a while ago.

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.

Size-wise it’s working!

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.

When the Shift key is held down — — — — — — — — — — — — — — — — — — — When the Shift key isn’t held down
This should work….But…. it doesn’t.

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.

Fixing 1 problem at a time.

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!

--

--