Why do we need to Make outside variables local for a Lerp Translation to work properly

Hello all,

So, I’ve just recently encountered an oddity when attempting to ‘Translate’ my Camera, made as a separate blue print actor, from one world location to another, via a Timeline and a Lerp node.

My intention is to move my camera from point A to point B, with a constant speed (no ease in or out) in 3 full seconds.

The Issue I found is that I have a different BluePrint that acquires the locations of Points A and B, and stores them. I then use a pure cast to that BluePrint to get said variables and their values and use them for my Lerp node as A and B respectively in this BluePrint. I also use a Timeline, with a length set to 3 seconds, with a float track that has two keypoints, one at 0, 0 for Time and Value, and the other at 3, 1, for Time, and Value. That Timeline Track is used for the ‘Alpha’ setting of the Lerp node. Based on that, the results should be that my camera translates from point A to B, in 3 seconds at a constant rate. See Pic below…

What I am seeing is that the camera translates to point B super fast, within 0.25 to 0.5 seconds, and not at the constant rate for the entire Timeline duration. Also, even though the camera already translated to Point B very quickly, the timeline still runs for the remainder of the 3 seconds, and at the end of 3 seconds, it then fires its ‘finished’ node properly. ( i have to set the value of the 2nd keypoint in the float track to something like 0.025blah for it to mimic the speed/duration i’m looking for) sooo…

What I found is that I seem to need to set my variables from the other BluePrint to be “Local Variables” within this BluePrint. By using those Local Variables then, the translation seen is smooth and runs properly for the entire duration of the 3 seconds as designated by the Timeline.

My question is why. Is this an Epic bug that just hasn’t been addressed yet? Did I possibly set it up wrong?
(Ive tried various iterations and other node configurations but this is the only way to get it to work)

I also want to ask that if this is normal, then should I just always, as a rule of thumb, whenever referencing ‘outside’ variables, to make them local???

I’ve been using 4.12 and just now 4.13 and this issue appears in both, and properly earlier version as well… perhaps.

Thank you for your time and consideration!

Sincerely,
Jaysinsan

The problem here seems to be that if you don’t save the position of the camera in a local variable everytime the update of the timeline is called it gets the current position of the actor. This position is then updated to the Lerp between the current position and your target position. On the next call of the timeline this position has updated again and you are using the new position as the start of your Lerp. Because of this the Lerping seems to be faster than expected.

In your graph you are saving the position of the camera BEFORE starting the timeline just once. This means you always Lerp between the same positions and the speed of the Lerp is as expected.
If you want to Lerp like this you have to save the starting position of the object you are moving before you are starting to move it so you have a constant value for A of your Lerp. Thats what you are doing by setting them as a local variable.
Maybe just call them CamStartingPos or something like that and it is clear what is meant by the variable.

For your second question, you should always save your outside variables as local variables if you plan the edit the variable on the outside object but your function has to work on the variable before the editing.

That makes sense…
I can totally see that if I’m getting the ‘get actor location’ every time during the lerp, and that location updates when the actor moves, then it would seemingly increase said translation speed as the actual length between the two points shortens each time.

Ok based on that, I’ll run another test to see if i can ‘get and save’ in the outside BluePrint, the actors starting location only once as point A and bring that variable in… otherwise… as you said in the 2nd part, it may be beneficial to always set outside reference to local.

Just curious and thank you very much for the reply!

Yep, after testing a few ideas you are exactly right sir about that. Always user error when i’m working with things! :stuck_out_tongue:
Thank you again for your help!!