For my project i want the player to be able to consume items that give him a stat boost.
Though instead of a instant 100% effect until the duration is over i wanted the boost to first ramp up to 100% effect over a second and then taper off during the next 5 or 10 secs.
To animate this i used a Timeline component as seen in the screenshot here:
However when the player consumes a similar item within the duration currently it just “resets” the timeline playback to 0, for my project i want a new timeline (with the exact same curve/statistics) to start playing to stack ontop of the previous consumed item.
Though i havent found a way yet to run multiple of the same timeline at various moments in time to be able to stack the resulting effects ontop of eachother.
Is there a better way to go about creating this functionality?
instead of a timeline use a “Timer”. you can loop them and tell how fast they should tick.
now back to your problem. what you need is a second variable, a multiplicator, that determines how often item is consumed. multiply it with your value. on standard its 1, if you consume an item its 2.
then I would make a second float variable as an array. everytime you consume an item it counts its value down once a second. so you have a timer which launches an event/function. there you make a for each loop and substract 1 every second from each element. if an element hits 0 you delete the element out of the array and decrease the multiplicator by -1. if you consume you obv add an element with its lifetime value and add +1 to the multiplicator.
if the array has no elements you can “clear timer”.
hope that makes sense