Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • 0
Melonpizza

How can I let an inventory item deplete passively?

Question

Hello

I was implementing a overheating mechanic by giving the player an inventory item upon firing, which would trigger the weapon to switch to ready upon reaching a specific amount of the item, but i couldn't think of a way to deplete it outside of having the weapon out with the overheating mechanic.

Any sort of help would be appreciated.

Share this post


Link to post

2 answers to this question

Recommended Posts

  • 0

Off the top of my head, I have two ideas.

 

Quick and dirty way: In the weapon's Ready state, it will remove the inventory item every so many ticks. If you swap to another weapon, you can put something in the Lower state to remove a set amount of the item (or clear it entirely).

 

More thorough way: Ignore modifying the Lower state above, and instead in every weapon's Ready state, apply the same item removal code that the new weapon has, so that way if the player switches to the Shotgun for example, the cooldown for the other weapon reduces at the same expected rate.

Share this post


Link to post
  • 0
On 8/28/2023 at 12:15 AM, SMG_Man said:

Off the top of my head, I have two ideas.

 

Quick and dirty way: In the weapon's Ready state, it will remove the inventory item every so many ticks. If you swap to another weapon, you can put something in the Lower state to remove a set amount of the item (or clear it entirely).

 

More thorough way: Ignore modifying the Lower state above, and instead in every weapon's Ready state, apply the same item removal code that the new weapon has, so that way if the player switches to the Shotgun for example, the cooldown for the other weapon reduces at the same expected rate.

The Quick and dirty was my temporary solution lol

 

But thanks! how didn't i think of that!

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×