Turret Turn


Week 3


With the kart system done and finalized, it's time to move on to the primary gimmick of the game, the tank turret.

This first week was getting the turret rotation down. The goal was to rotate the turret based on player input from the arrow keys. However, it's not as simple as reading the last arrow pressed and setting the rotation based on that. Various edge cases had to be considered.

For example, what if the player presses left then right without letting up on the left, then releases directly? If we only considered the last key pressed, the turret would rotate back to forward-facing when the right was released despite the left still being pressed.


(More use of Odin Inspect)

The solution was a sort of queue system. Every time an arrow key is pressed, it is added to this list. And, of course, when released, it's removed. With this, the order of key presses is saved even if the player pressed a new key while still holding the previous key. So, it always registers if a key is pressed, even when a more recent press is released first.

As a slight visual detail, a slight wobble was added to the turret upon reaching the target rotation. This gives the rotation a feeling of weight, not just a model being rotated by code. This wiggle does not affect the underlying data tracking which way the turret is facing and will not affect how the turret's recoil moves the vehicle; it's just an excellent detail.

Next week will be on implementing the effects of firing the turret, starting with the boost from firing in reverse and moving on to the sideswipe. Thanks to the ball-based kart system, this should be easy.


This concludes this weeks report.

Previous
Previous

Fire Away

Next
Next

Stage 1 Clean-up