How to make an object go from one point to the next using timelines

the basics of moving objects with timelines is pretty simple as long as you keep in mind that its best to use static locations for the start and end points. If you try to use non static locations then you will end up with acceleration issues or erratic movement.

ok so here’s a little explanation and example. to begin you will need two locations (start & end), here i use the actors (this is the actor that will be moving) current location (StartPosition) and i have another vector variable for the end location. to populate the information needed for the end location you could manually enter it, use a trace to locate a actor, or use some other method as you saw fit. for the start position as you can see in the below picture i got the actors location then i set it to a variable (we set a variable to have a static reference. one that won’t change as the actor moves). next comes the timeline which will consist of a float track with a value ranging from 0-1 over X seconds. to create a new curve/track in the timeline just double click the timeline node, then click the F icon near the top left to create teh track, and finally shift click the graph to add points/keys to it. also when i said over X seconds earlier the X stands for how long you want the movement to take, basically how long to go from point A to B. speaking of A to B, connect your locations to a lerp vector node as shown and then connect the timeline to the alpha pin. the lerp returns a value between a and b based on the alpha (0-1). so if the alpha is 0 then we get a, if its 1 then we get b, if the value is 0.3 then the lerp returns a location one third of the way between a and b. it works on a continuum so it can return a location at any point between the two positions. the last thing we need is to set the actors location via the set actor location node. we call the set location on the timelines update which for the example we will say runs on tick (gets called many times per second). since we are setting the location so rapidly and we have locations that are accurate we now have the illusion of smooth motion (like a movie).

there are a ton of ways you can modify this script and call it from different locations as needed depending on the situation but thats the basics of movement on timeline (get locations->define movement over time-> set location rapidly based on lerp). oh and if you want to have the cubes line up then you will need to provide a offset to the end location.

1 Like