Turning It Around

This entry is part 2 of 4 in the series Space Game

Previously on Space Game. . .

Last time I got the beginnings of a game built. A simple sandbox that you can fly around and an objective to touch. No cool animations, effects, or anything really. I was left with a bit of a list of things to work on:

  • Ship rotation
  • Correct thrust mechanic
  • Pause Menu
  • Main Menu
  • Ship Design
  • Enemies

And Now. . .

Rotate!

First things first, rotation. It took a little diving but I figured out how to add new keybindings. It really isn’t very intuitive. You have to change “Size” in the Input Manager. So strange. But then I realized I only needed to add a single key, with a positive and negative axis.

Then came the coding. That was actually pretty simple too. All it took was a single line, although I did it in two. The first was declaring a variable to hold the rotation axis, and the second was to actually rotate the object.

Strangely, adding rotation caused a stutter. I don’t quite understand why, even when the ship wasn’t rotating it would jitter. Commenting out that code would make the problem go away, but then I can’t rotate. After taking all the movement code out of the Update function and putting it in FixedUpdate the problem was solved! Or so I thought. . . Not sure if it’s just an editor issue or something more. Gonna have to figure this out!

Thrust

Implementing a thrust mechanic that allowed for modifiers based on direction seemed daunting. I spent a while thinking about it and couldn’t come up with anything that made sense. So instead I just dove in, did some googling, and came up with a solution!

First, I needed variables for my thrust vector modifiers. Four new public floats and then it was time to do some research. I had no idea how I was gonna make it work, and couldn’t even come up with a great way to word it for searching. In the end it came down to adding four If statements like this:

if (vertical > 0) { vertical *= ForwardThrustMod; }

Next Time . . .

And so, rotation is added and the thrust problem is solved! That still leaves A LOT of work to do. I’m not sure what to work on next though. I’m adding more things to my list too, as you can see below.

  • Ship rotation
  • Correct thrust mechanic
  • Camera Zoom
  • Pause Menu
  • Main Menu
  • Shipyard
  • Enemies
  • UI
    • Objective indicator
    • Ship shield/armor
Series Navigation<< Space GamePersistent Data >>

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.