(Problem) Variable Prints 3 Times Per Tick
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"
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.
answered Dec 06 '18 at 03:40 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here