Hello, I’m leaving a question because I have a question regarding the timeline node.
My intention is that when I click, the main player moves a constant 10 in the X-axis.
Timeline nodes consistently output values of 10, but when connected to the add node for player location change, the values are output differently, so the desired constant movement is not implemented.
When you print your float track’s value multiplied by 10, you might see that it ends at 10. But that doesn’t mean that the timeline has updated 10 times and teleported the actor 1 unit further on X axis each time.
There are many ways to smoothly move objects for a certain distance! You can trigger their movement constantly using a timer, timeline, or after a gate connected to Event Tick, and constantly check if they’ve reached the target location¹ or if the movement has been triggered enough²; or use interpolation³.
Due to float precision, it’s near impossible to detect when exactly an object’s location is equal to our target location. So in the checking method where we compare the locations, we’d either round the values, set a tolerance, or move the actor on a spline and detect when it reaches the end point.
This could be a bit of an overkill for your simple task, so let’s move on.
In the other checking method, we’d either use time and the actor’s velocity to calculate the distance it has traveled but that wouldn’t be reliable like those first two options in the first method, those where we don’t use a spline. Instead, we can save the cummulative movement input or the iteration count and stop triggering the movement when it reaches.
Now that we’re done with checking methods, it’s time for the best approach for your specific task!
Remember when I said the timeline doesn’t update the amount of times you expected it to? Well that’s not a problem, because you can interpolate the time passed between your desired values!
These being said, here are the two approaches you can go with:
Below are the updated versions since the previous ones were frame dependent
(You can also set the actor’s world location too but adding local offset is more practical. Got a bit long though in order to make it frame independent so this might not be preffered.)
(And here’s the one I’d recommend more for this task. Like@Everynonesaid, my mistake here was not saving the actor’s location before triggering the timeline, also the float track’s value was plugged into the wrong pin of the finterp node.)
@VisAgilis None of these 2 would move an actor x units over the duration of the TL. They’re both frame dependent and the 2nd one would be more inconsistent because of the double interpolation. Run it with different framerates to see how they behave.
Not saying the script is wrong, it has its uses - the 2nd one is a glorified super dampened spring which definitely has its uses - merely uncertain it’s what OP asked about.
They’re both. Depends on how you use them. The Update pin fires every frame: more frames = more udpates = more motion. That’s why one generally lets the TL do its own interpolation that relies on time.
Tested my first screenshot, it seems like it does move the character exactly 10 units on X axis smoothly on different framerates. Are you sure? Could you also test it for yourself? I’ll also take a look at the second one.
Movement Components / input nodes account for frame delta. This does not make the timeline use correct. Move a cube over 1s at 100fps and at 10fps and you’ll see what I mean.
I get what you mean now!! I was gonna share videos with 30, 60, and ~200 fps but just as I was gonna post I noticed your edit about 10 fps, and I wanned to see what it’s like then as well. Yeah, it moves slower! The difference between the other relatively high framerates were unnoticeable. Well, it’s awesome to start a morning learning new things from @Everynone