This week I focused on adding core mechanics that were needed for the game to run. I began by adding a score system that, whenever the player dies, calculates a final score by multiplying the year by a score multiplier. This score is then saved in the PlayerPrefs file, which saves variables even after the game is closed and restarted, under “score”. If the score is higher than the saved high score, also stored in PlayerPrefs, then the high score is overwritten with the new score value. Whilst there is currently no way for the player to access their score, I have added a Text Mesh Pro to the start screen that displays the high score.

The multiplier, displayed at the top of the screen, was then implemented. This value is tracked in the score manager, which calculates the final score at the end, and is intended to be updated whenever the player achieves a feat; feats range from collecting meteorite gems, to reaching specific heights. As meteorite gems have not yet been implemented, I decided to use the fuel pickups to increase the value, for testing purposes. The other addition I made to the score multiplier was making its text display flash white and red whenever the value goes up; doing this makes the game feel more responsive, and also draws the player’s eyes to the reward that they would’ve just earned.

I also began adding some key art assets to the game, beginning with the rocket asset. When adding this asset, I also needed to reset the polygon collider attached to the rocket. However, doing this caused the rocket to tilt slightly left and right whenever it was touching the planet surface, which resulted in the rocket taking off at a slight angle. The video below shows this bug in action.

bug sideways.mp4

To fix this, I attempted to adjust the collider and make the bottom a single flat surface, but I was still getting the same issue. After some research, as well as experimentation, I found that it is possible to freeze the rotation of a rigid body in Unity. Once I had done this, the issue stopped occurring.

The final assets I added were the planets in the background, which move slowly along with the rocket. Initially, I planned to use a similar script to the one used with the stars, where the planet moves with the rocket, only slightly slower. This approach, unfortunately, caused the planet to constantly stutter whenever the rocket moved; the stars also do this very slightly, but it is so imperceptible that no change is needed. With the planets, I tried a different approach that, instead of adding to its transform.position vector to move it, completely reassigns its transform.position to that of the rocket’s plus a slight offset. This happens every frame. The offset is then increased, or reduced, according to which direction the rocket is moving, if the rocket is moving at all. This system causes the planets to slowly move down when the rocket is going up, and slowly move up when the rocket is going down.

To reduce the load on the game, and not have game objects thousands of pixels high from the get-go, I utilised one game object to hold each of the planet sprites. When the rocket reaches a specified height, which is also when the planet would be offscreen, the script resets the offset and swaps the sprite out for the next planet. This means that the next planet becomes just offscreen, above the rocket, ready to move down. The script works the same for positioning planets below the rocket, if it is travelling down, only slightly different heights are used and the offset becomes negative, to position the planet offscreen below. The video below shows the progress made so far.

score multiplier.mp4

Next I began work on improving the patterns and ensuring that the game is indefinitely playable, and will not unfairly kill the player. This started by adding fuel pickups to every pattern, so the player always has the opportunity to pick it up. I also added new slightly harder patterns, and have now implemented 7 patterns. Finally I added meteorite gems to some of the patterns, which add 0.1 to the score multiplier. The video below shows each of these changes.

low fuel indicator_Trim.mp4

Finally, I was able to fix a bug that had been occurring since the start of development. The bug allows the player to fall through the planet surface if they are going fast enough, or even get stuck inside it. The videos below show the bug in action. I was able to fix it by simply making the planet surface block much bigger.

bug stuck in floor.mp4

bug fall through floor.mp4