Move and rotate mesh along spline

Hey guys,

I’m trying to create an animation of a garage door, so it will be a couple of meshes following a spline.
I’m having trouble understanding how to set up my spline.

So here’s my mesh and the default arc spline:

The mesh correctly follows the spline and rotates 90° around Z in this scenario.
My idea now was to rotate that spline, because this is how I want to move and rotate the mesh (90° on X):

But that doesn’t work, it will also rotate the mesh in some weird way:

This is the blueprint, I got it from a Youtube tutorial:

Please let me know what I’m missing.

you seem to be almost there. The way I do it is that I set “Current Point” and “Next Point”. Current Point and Next Point stores point into them by callcing “Get Location At Spline Point” i and i+1. Then lerp it from 0 to 1 and update then update “Current Point = Next Point” and “Next Point = Get Location At Spline Point + 1” and move again. I hope that makes some sense. But if it doesn’t I can elaborate more.

Thanks for your reply.
I think I don’t have enough experience yet to understand what your suggestion will do.
Please elaborate a bit more :slight_smile:

So think of it as having spline with multiple points. You have access to what the location is at a specific point on spline. So using that we can do setup like this:

Index will keep track of which point you are on. You will start with 1 in this case. That is because we will store point 0 as current and target as point 1 (index). After that we do the lerp. Lerp has to be between 2 non changing points for the duration. You can change speed by changing timeline. mine is from 0 - 1. Below image is an example:

After the lerp (timeline is done) you have reached to target point. You add 1 to index, check if you have reached the end. If yes, the you exit. If no, you make make current location = target location, get next spline point using the incremented index and save it in target location and run the timeline from start again:

This will keep running till you reach to the end of spline.

NOTE: you have to take care for 1 thing. I.E. if you want the location to be in world space or local space. You can change that when you use the function “Get Location at Spline Point”

Thanks, I set it up like that but I have two issues.
It’s doing exactly the same thing as the first solution I posted.

It’s moving the mesh in the direction of the arrow, not up and forward like the spline is oriented (spline has 90° rotation on Y):

Also, I tried to add rotation like this but it’s not rotating at all:

I printed the XYZ values of Get Rotation, but there is no rotation at spline point, that’s why.
How would I do that?

are spline point and the actor you are moving in same actor? Also can you try changing coordinate space from local to world?

No, they are separate blueprints.
Switching Get Location to World fixed the movement, it’s now moving along the spline.
Do you have any idea how to make the rotation work?

If you click on point, press E and rotate it, that will change its tangent. Instead after selecting point, go to properties and enter desired rotation. I have marked it in above picture

I think that answers all of your questions. Is there anything else regarding this topic you are confused about?

The points are already rotated, but the mesh doesn’t rotate.

This point for example has -45:

UnrealEditor_l03MBbzjtW

UnrealEditor_CoG8Vl7oom

But when I simulate, the mesh just stays upright, it should rotate like a garage door:

Even when printing it like this it just gives me 0:

I deleted this spline and created a new one.

Now it rotates on the Z axis:

But I want it to rotate on X, what do I have to change to do that?

If I change it to World then it does the correct rotation, but the whole mesh is rotated this way then:

My god, how complicated can this be…

Lets see. I have tried this on my side so I am posting everything here

Spline and Cube being different actor and then I have written all the code handling in level blueprint for now.

Initialization:

This is just setting variables that I am going to use

Timeline Execution:

Instead of 1 lerp I am using 1 for location and 1 for rotation.

Post Timeline Execution:

It basically just updates point and executes timeline again if needed. The result is below in gif

Mostly I think problem can happen with if you are choosing world or local. There are going to be rotation problems as well but thats for another time.

1 Like

Spline can be annoying. Generally mistakes happen where you won’t expect them. I have had a massive work done in splines one time, which taught this to me quite a bit but it was frustrating to start out with. You’ll get there. Till then you will have to try over many times :smiley:

2 Likes

Thanks for your effort, it is much appreciated!

This is my solution now.
I’m just replacing X with Z and everything works. Sucks, but that’s what it is :joy:
Maybe I’ll figure it out in the future.

1 Like