Best Way to Make Values Interpolate to 0 Over Fixed Interval?

Godot-4.4

I could post code but I think it would probably just overcomplicate the question. Basically, I have status effects that work off of stacks. The idea is that enemies can have different resistances and things like that which change how many stacks are needed to proc a status effect on them, and that works but the issue I’m having is I want the stacks drop off over time after not hitting the enemy for a certain interval. For example an enemy could take 100 stacks to proc a burn effect, but if you don’t hit the enemy for 3 seconds, the stacks will begin to drop to 0. I know I could do a lerp by a specific value like 5, reducing it over time by 5 until it reaches 0, but I specifically wanted to be able to control how long in seconds it takes for it to fall off, so something like this effect takes 10 seconds to drop off and there are 80 stacks so it would drop off 8 stacks per second. I thought of tweens but I might be misunderstanding documentation, it seems like it would be a little annoying with a large set of values having to set up a tween for each, but again I might just be misunderstanding or missing something.

No, you can use a tween. You can make a function that takes in a stack, and length of time, and then call that one function every time you need a tween.

Ah that makes since so it would make one completely independent to each one when needed?

Yes, tweens will automatically be freed by default when they are done tweening. They’re meant for you to create once and not think about them again.

Nice, thank you for the help

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