How to update timer with a variable realtime?

Hello,

I have a function which starts counting when the event is constructed. With the Time Scale float I want to update how fast that counting happens (1=1 sec, 0,5=2 sec, etc…) but my problem is, the Event Construct is firing only once as the name states. I tried to connect the function to the Event Tick but then it is not counting since it wants to create the counting every time by whatever number is written in the float.

I want that if I change the Time Scale float, it updates but changes the timer too. Can somebody help me, please?

Promote the return value to a parameter (a timer handle). Once you have the handle you have access to the timer for later use.

Promoting to a variable makes the same as I did (like I’m just renamed the float). The problem is not the access but how to change realtime since I can change it but will affect nothing because the Set Timert by Function Name will fire only once, when the event is constructed.

No you need to pull out the Set Timer Function Name return value (the blue pin) and promote that to a timer handle variable, then use the timer to change parameters in the timer at runtime.

You can also invalidate a timer and reset it after the change.

1 Like

I did not notice the “return” word, my bad. After I promoted it, where can I set any value to it? I cannot see anything at the default value or any changeable value

Is invalidating the timer and restarting it, saves the variable values inside of the function? Because it is basically a counting function and it won’t be good if it would start over from the default values.

The timer only calls the function. It does not own the function so when it ends the function is still accessible.

You should probably use a variable with scope outside of your function to track stuff.
If it’s a local variable it will become invalid after the function terminates.

1 Like

I achieved what I wanted with the Clear and Invalidate Timer by Handle node, then restarted it with an another Set Timer by Function Name, massive thank you for that!

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