How would I do something like this?

Hello,

I would like to run an event within my blueprint, however I would like something like an instance of it to run, so that multiple could be going at once.

For instance in the blueprint below, I would like to have Testint be incremented by 1 and then decremented by 1 after four seconds, no matter how many times I call it. As it runs now, if I were to rapidly call if five times in a row, it would increment to five, and then decrement once. I would like it for increment five times, and then four seconds later decrement five times. Is something like this easily doable?

You can use a timer for that i guess. Everytime you press T, you reset the timer to 4 seconds.
And if you want to subtract the same amount you add, why don’t you just reset the variable to 0 or its starting value?

Unfortunately a timer has the same pitfalls. If I do something like this:

then it will behave the same way as before. The reason I don’t just reset the variable to zero is because I would like an effect to wear off in the same rate you got it. Say for instance you had an ability that was a heal over time, and every use gave you 1 hp/s for 20 seconds. If you casted it once, you would have that 1 hp/s, and then 10 seconds later casted it again, you would have 2 hp/s. After 20 seconds though the initial cast wears off you are down to 1 hp/s, and after 30 seconds back to 0.

I’m looking for some way to easily increment and decrement with delays that don’t over ride eachother

Got something for you i guess. As long as i understood what you need.

http://puu.sh/aDy00/c085babcd7.png

So the retriggerable delay resets if it gets a trigger before finishing.

What happens here is the following:

  • You press your button and it adds 1 to the TestInt.
  • If you press the button a second time before the 4 seconds are over, it will add 1 again and reset the delay
  • If you dont press it, the Boolean will be set to true.
  • Now the tick Branch is True. You directly change the Bool to false again, so that the Tick isnt called again
  • Than you check if your TestInt is greater than 0.
  • If yes, you call a delay (i guess you can use the normal here) and after 4 seconds you lower the IntTest by 1 and check again if its greater 0
  • If still greater, you call the delay again and so on.

I just saw, that you call the delay after the first delay. So its 8 seconds.

You could change this by using a Float Variable for the second delay. Set it to 0.0 if the Branch that checks the TestInt is False.
set it to 4 after the TestInt was lowered the first time.

Hope that is what you are searching for! (:

EDIT: Ok once i posted it, i saw some issues. I reworked it:

http://puu.sh/aDz4u/f2cb761fb8.jpg

So now he starts directly after 4 sec and than sets the second Delay to 4 seconds until TestInt is 0 again.

If you press the button while hes already Subtracting you add 1 and only reset the second Delay instead of calling the first delay etc.

Guess that works. Need to save that for my own buffs xD

You may have to just track your increments in an array and then use a timer to “count them out”.

Every time an increment happens add it’s game time to an array of times. Have a timer that does a check for anything in the time array and decrements your count and removes the index from the array if its over your time amount.

You can turn the timer on whenever you get an input to increment and turn it off when the array length hits 0. This way it only runs when something is around it can handle.

Thank you this sounds like the ticket :slight_smile: I think I will likely have to go another route however. I was asking this question because I wanted to make a buff / debuff system where I could easily put on stacks of buffs and take them off. However, I think this approach is best for single behaviors, because if I have to have as many checks as I have buff types it would bog things down quickly.

Likely I’ll have to create a custom Buff class that handles its own lifetime and removes itself. I don’t think I can do this in Blueprints so it’s time to figure out C++ in Unreal heh

Thanks again for the response

I do think this would be more elgant in C++. If i had to do it in BP then i would probably make a buff manager class that had an array of structs (buffs). Each tick/timer interval i would check each index in the array for a time attribute.