This is a bit difficult to explain, but what I’m trying to do, is make it so that one object with, for example a cube underneath it, will line it’s self up with another cube in the distance using timelines, basically, I want it to get the location of the cube in the distance and smoothly travel along to that cube and basically line up with it.
Example: (This was simply made using a level sequence)
What I’m looking for was kind of hard to explain, so I’m hoping the gif will help, basically I want to create the gif but using timelines and blueprints, I should also point out though, that the cube moving would be attached to a blueprint, for example a vehicle or moving platform, so from what I’ve tried already, I can only use a SetWorldRelativeLocation (Or whatever it’s called)
Again, sorry if it’s not clear, but thanks in advance.
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.
OK, so this seems similar to what I’ve tried already, but the last part intrigued me, what do you mean by, “provide an offset to the end location” and how would I do that?
OK, so it’s not really working, because as I mentioned, I’m controlling the object from within the blueprint it’s self, so the only node I can use is, “SetRelativeLocation” as the target is a scene component and not an actor, this I think is one of the reasons why it’s not working, put it this way, I tried it, and the object teleports miles away, so I have no idea what I’m doing wrong. I suppose I didn’t mention also, that I’m new to blueprints, so honestly, I’ve probably got it setup completely wrong.
I’m controlling the object from within the blueprint it’s self
i would usually take that to mean that your working inside a actor, but from the sound of it thats apparently not the case. so if your not working within an actor where are you placing the script? if your seeing set relative location and not set actor location then it doesn’t sound like the level bp either.
oh and if its just a component on its own then i don’t think setting relative should work since there is no separate root object to act as a origin.
what do you mean by, “provide an offset to the end location”
what i meant here is if for example you have set your end location to the location of the second cube, in that case the moving cube will move to the same location as the end cube resulting in the two overlapping. if instead you set the end location to be offset by say 100 on the z axis then the moving cube would end up just above the end cube (endpoint + vector (0,0,100) = proper end location).
Hi, I know a long time has passed since the post, but I am trying to do something similar, but with dynamic start and end points… and yes, the acceleration differences is an issue… are there any suggestions as to how to resolve this? I didnt find a way to set the duration of the timeline dynamically… any help would be greatly appreceated!