# (Problem) Variable Prints 3 Times Per Tick

Hello Everyone,

So my problem put simply is this. I have a Timeline in UE4 Event Graph running from 0 to 1 on loop. I have some presets that will manipulate the playrate, i.e. if the preset it set to “Real Time” it will set the playrate to 60 and every time the Timeline reaches 1, it will increase my variable called “Milliseconds” by 1, and every time Milliseconds equals 59, it will add 1 to my variable called “Seconds” then reset Milliseconds to 0. It continues on for Minutes and Hours respectively. All of this happens inside of a blueprint function.

The clock works great, but here’s the problem. If I tell it to print out Seconds inside the function, it will do just that. (0 to 59); however if I ask it to print out Seconds OUTSIDE the fuction (In the Event Graph) It will print out each number THREE times. (0,111,222,333, ect.) So later on I call the variable, normalize it to a range so it gives me 0 at 0 seconds, and then 1 at 59 seconds, and then plug that value into a branch “When Seconds, normalized, equals 1, Do this thing…” It will do that thing THREE times. Ex. When seconds, normalized, equals 1, add 1 to Variable “A.” Instead of adding 1 it adds 3.

(I blacked out some nodes to make it easier to read)

Does anyone know what is causing this, and either a way to fix it or a work around.
I tried creating a local clock within the second function, and that worked, but I don’t want to have to create a bunch of local clocks when I have a global clock that is exactly what I need.
I’ve also tried a “Do Once” node inside the function, and that didn’t do anything.
My theory is that it has to do with a looping timeline. When I tried to print the alpha of the timeline, it would give me “0.0, (Random number inbetween 0 and 1), 1.0”

Any thoughts?

well there is a bit of context missing (for example where do you print that number), but you described that your do once isnt doing anything.

I guess you used that Do Once inside a function. Well each time you call your function all local variables get resetted, so if you call that do once twice in two different function call, it counts as not called in that function call.

If you would call it twice in the same call, then it would remember that it was already called

I solved the problem by just creating a new clock inside the function.
I was printing it to the screen on play, and yeah the Do Once node doesn’t work properly inside a function because of what you mentioned. Either way the Print and the Do Once aren’t the root problem. The print just confirms that the action is happening 3 times every tick.

The initial problem still remains though. Don’t know why it was doing the action three times rather than once. Clock is running inside a function, that function gets called every tick, relaying information to another function, but that function is getting an input 3 times a tick. It’s very odd considering all my other functions receiving the same information from the clock only act once. It’s a conundrum.

Hey! So this bug was fixed with 4.21.1!

“Bug Fix: TimelineComponent Update delegate will no longer execute three times when looping.”

Unfortunately it broke the timeline too. R.I.P. If you set the length of the timeline to 1 and having two points going from 0,0 to 1,1; the timeline will never actually reach 1. So when checking if the alpha reaches one it will return False.

Increasing the timeline to 1.01 will sometimes still miss hitting 1, and increasing it to 1.02 seconds will sometimes return 1 twice. There’s no way to win here.