Item Functionality and Saving with Items
Author: Zak Levine
Date: 3/17/2023
A significant aspect of many games is items or consumables. For Slimegeon, we decided on two types of things. Permanent items will alter the player's stats for the entirety of the run, and temporary items will transform the player's stats for some time, but with a significant boost in quality. The latter came with more challenges and bugs.
The permanent items were relatively easy to implement. The object would affect the player's noted stat and disappear when collected. The item's effect would be permanent when the player saves the game. However, for the temporary things, when assembled, they needed to attach to the player so that they could be used when the player would like to. Items the player held on to meant they needed UI reminding the player what it was and how long it lasted. And all of this needed to be saved. Another aspect was multiple items. We decided that a player is only allowed one thing at a time. If a player chooses to collect another temporary item, the item currently on the player must be stored in the chest instead of destroyed. The feature of swapping the items came with the greatest challenge of all for me while making this system.
To solve the challenge of the item functionality, I wrote a function that takes in a float, Time, and Max Time. Then I repeated this function with a .1f delay and added .1f to Time each iteration. By doing this, I could display the Time left of the item using Max Time - Time. The function would give the user a clear indication of how long was gone on the thing. The procedure was modular so that I only needed to change a switch case on the body and could reuse the same process for every item. I also implemented single-use things with a Max Time of 0 to only loop once and not display the 0.
Saving items came with many challenges I had to think about when implementing. For instance, what if a player tried to save when they started using an item in hopes of refreshing the timer. To combat this, I added a used bool that, if valid, would not save the object. I also made sure to use temporary variables that would not be saved for any stat that was not supposed to be saved. My biggest challenge, however, came with swapping items back to a chest. The main issue was once you changed an item, you could not switch the thing back or even grab the exchanged item. After much debugging, I realized I was not setting the item's parent to the chest; instead, I only put the chest's Item reference to the object. After further debugging, I also found out I needed to add a delay to the things swapping and select the article I just placed back in the chest to true for Player In Range. Through this system, I can add any amount of items by only adding a new case and functionality for the entity making it modular, easy to use, and reusable.
Slimegeon
Status | In development |
Author | zaklev |
More posts
- Finalizing the Skill Trees and the Missile TurtleMay 25, 2023
- Creating Modular UIMay 25, 2023
- Sword Reveal Over TimeMay 25, 2023
- Bug Fixes and CinematicsMay 25, 2023
- Fixing Pawn JittersMay 18, 2023
- Reworking the skill treesMay 18, 2023
- Reorder Save List by Date Last PlayedMay 18, 2023
- Possession, Lock-On Blips, and YetiMay 18, 2023
- Loading Screen and Lock On AdjustmentsMay 11, 2023
- Snowballs Destructive MeshMay 11, 2023
Leave a comment
Log in with itch.io to leave a comment.