Thursday, 19 April 2018

Stamina, Pause Menu

Within the last week or so I have been working on implementing a stamina system. This stamina system gives the Player a reason to go back up to the surface and allows me to implement a use for the consumable items. Upon starting my development of this system, I outlined three potential interactions for this stamina system:

·         Stamina will drain at a steady rate over time.
·         Increased further when mining, even if not hitting a target ore.
·         Increased even more if the Player is actually mining a rock.

In order to get this system to work the way I wanted it to, some of the mining code needed to be restructured as I couldn’t get it to work with the current system. To implement this solution, I first needed to move all of the mining code off of the Player and into a new script. Not only was this for peace of mind and clarity, but also to segregate the process so that the logic could be more easily determined. I separated the mining code into three logical steps:

1.       Every frame, check if the Player is mining.
2.       If they are then run the MineRock() function, which fires a raycast.
3.       If the raycast hits nothing, then stamina will decay at a flat rate but if it did hit, then the decay rate will be determined by the rock that they are mining.







EDIT: shortly after implementing this change and submitting this post I noticed a bug with the stamina drain rate. The stamina decay rate was fluctuating constantly, sometimes it would drain quicker than normal. I couldn’t figure out the exact cause of this problem, but by moving stamina to its own script fixed this issue.

I have also implemented a pause menu as there was no way to pause / exit out of the game up to this point.

No comments:

Post a Comment

Download the game and Project Files!

The project files along with any additional documentation are located in this folder on my Google Drive. To download the game please down...