Inventory Item Degredation

Hey Guys

Just a quick question.

I have an inventory system in place which is basically an array of Structs which hold all the item specific information.

One of the item stats is ‘Condition’. Basically I want the item to degrade over time. So let’s say it starts with 100% condition. How would someone go about making it so when that item is in the inventory, it degrades over time. So I pick it up, it’s 100% (already done), and let’s say 10 minutes later, i check the inventory and the item has degraded to 95%. I’m just not sure how to get it to degrade over time.

I could always use a timer to modify the ‘Condition’ variable inside the struct, but wouldn’t this be costly if I have many items in the inventory that do the same thing.

Just looking for some ideas on how someone might approach this.


Maybe only update it everytime you need to?

Like maybe store a value saying when the item was added, then everytime the player needs to see its condition, update it?

With this you wouldn’t need to update it every minute or something, only when the player needs to see it.

EDIT: Spelling

Hey crispy, thanks for the idea. Seems to be the better way to go about it.

EDIT: Ok so i’ve tried to have a go at this but really don’t know where to start. I’m assuming I would do something like save the the Date/Time when In pick the item up, and when the player opens the Inventory, I would get the date/time and compare the 2 and deduct a certain amount of condition depending on the difference.

I seem to understand how it needs to be done, but not sure how to do it. Not sure of the right nodes to use and how I would compare 2 dates/time etc. If anyone is able to help with this, I would greatly appreciate it.

Maybe this can give you some inspiration: How To Tell How Much Time Has Passed? - UE4 AnswerHub

Get Real Time Seconds would be something to look at, but this doesn’t stop when the game pauses. Keep that in mind.

Using the Now node retrieves the system time in the form of Date Time struct. You could use this to compare against your stored value, but remember to accommodate for times which may go over 00:00 (new calendar day), and counting minutes that run past a new hour (i.e 13:46 -> 14:05)

You can experiment with something like this:

Store the timestamp in the pickup’s struct and the next time the user sees the item, check how old it is.

If you need to periodically check whether an item has expired, without user interaction, you can set the item’s Tick to something low, like once every 5s and have them check their own age (GetDuriation) with the above and only report via a dispatcher that their condition has deteriorated.

Thanks for all the replies guys. This is exactly the information I was after and should get me on my way.