Download

How to use different timer handle for the same function when using the set timer by function name node in blueprint?

Hi there,

I’m new to UE4.26 and having two problems to trigger one function periodically in a certain period of time.

First question: How to call the function once at start before it runs periodically and control the total looping time?

For example, I have a function called OnFireDamage. When I triggered it for the first time, I want to set a timer for this to trigger it periodically for a certain time. For example, I throw a fire ball to the enemy and set him on fire, so he would take fire damage every 1 sec for totally 5 seconds. As I want him to take damage at the very beginning, for 5 seconds totally, he should take the fire damage for 6 times.

When I’m using the set timer by function name node in blueprint, I didn’t find a way to make sure the function is called once when the timer starts. And I also can’t find a way to control the total looping time.

Second question: How to have different timer handle for the same function?

For the same scenario, I have the OnFireDamage function. If I fire the enemy with fire ball for the first time, it fires the enemy every 1 sec. And after 0.7 secs, if I fire the enemy with fire ball again, it would reset the previous timer handle and restart to fire the enemy every 1 sec.

As the Set Timer By Function Name node tooltips says that “Set a timer to execute delegate. Setting an existing timer will reset that timer with updated parameter”.

But I want them to run periodically both. For example, the very begining of the first fire damage starts from 0 in timestamp, and run periodically every 1 sec. And the second fire damage starts from 0.7 secs in timestamp and run periodically every 1 sec as well. But the Set Timer By Function Name node automatically resets the timer which I don’t want to. How can I avoid this?

The timer won’t run immediately. If you want that effect, you have to call the damage node at the same time as setting up the timer.

To stop the timer after a certain number of iterations, you need to count them and invalidate the handle when you reach X iterations.

The other scenario you’re describing is actually two timers, you can’t run one timer with two timer handles.

image

Wishing for Initial Start Delay to be 100% reliable in UE5 :expressionless:

Does that work?

Normally, yes. It almost always does. Until that one time when it does not, leaving you scratching your head for 30mins.

Calling it manually after starting the timer does it, as you suggested.


On an unrelated note, thought I’d share my morning snafu. Don’t do this:

image

I am aware of pure node evaluation and still hook things up like that every now and then.

:skull_and_crossbones: Effing Rookie Mistake :skull_and_crossbones:

The chances of that loop ever iterating 12 times are like 1:10000.

So it probably definitely might?

Yeah, gotta watch that pure node stuff… :slight_smile: