simpler energy drain system in my game


In my character blueprint I have a system that every 1 second checks the hunger the player has. if they have a lot they have less “energy draining” if they have less hunger they have more “energy draining”

this system works but I was wondering if their is a more efficient method instead of using lots of branches and greater than nodes

You can do this via a bit of math

The maximum terrible-ness index just makes it so that you can’t go above 2x drain rate. Ie if you make the maximum index 6, >=625 will now be 5 and result in a drain rate of 2.5, 1875 will now be 4 and result in a drain rate of 2, and you’ll need >=6875 to reach an index of 0 and drain rate of 0.25 again.

2 Likes

You could also use a map to keep it cleaner, I don’t know if this would work because I’m not currently on an empty project, but in theory it should get you to some point:

Thank you, this worked good for what I was trying to achieve :grin:

1 Like

or a curve which has the advantage of being a separate asset for easy tweaking

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.