Hi, I’m learning how to use splines and want to move a sphere along a spline which is in shape of a sine wave. Once the actor moves and reaches the end point of the spline, it needs to stop in that position. And based on a value received through a variable, the movement of the sphere should reverse along the spline and reach the 0th point of the spline.
I wanted to use a spline to control the movement along a specific path, would this be the best option to do it? And is it possible to achieve something like this? The tutorials I’ve looked at showcase an enclose path where the actors move in a loop, but I don’t want this to be the expected behaviour. I tried to make a variation of it from the tutorials, but on hitting play the sphere moves into a very jittery fashion.
So if you could supply screenshots, video of what’s happening, the tutorials you’ve followed, et cetera… It would be a big help in assisting you. Right now we’re just kind of playing around with theoreticals? But yes, you’re on the right track for moving along a specific path.
Hi @Mind-Brain, thank you for your response. It was a bit of theoretical visualisation and experimenting. So far, I’ve created a blueprint for a spline and a sphere, and referencing the spline in the sphere’s blueprint, and using a custom function MoveRight to make it move. I’m not sure if the jerky behaviour as you can see in the video is caused by the spline itself or the timeline. The spline is extremely simple and has only two points as of now.
Thank you, I tried this. The movement isn’t jerky anymore. However, it’s still not following through the entire spline path. The reverse function doesn’t seem to get activated either.
Also, can you please tell me how to align the actor with the spline? I assumed it would happen when you set the transform values to be the same, but it still doesn’t match as expected.
swap the move right and move left calls around after the switch. That should fix it not playing in reverse.
Don’t know why that would happen unless your alpha curve doesn’t fully go from 0 to 1. You could try checking “Use Constant Velocity” bool in the Get Location at Time (Don’t know if it’ll make any difference.)
[Edit] just noticed that the MoveLeft Custom Event is connected to Reverse instead of Reverse from End, that could also be a reason for it not reaching the end. It shouldn’t really matter if it’s Reverse or Reverse from End, but worth a try.
What do you mean by alignment? Should the rotation of the actor match the rotation of the spline at current time? if so, there’s also a Get Rotation At Time function available on the spline. You can use that to set the rotation.
Something like this aligns the actor only on the Z axis, making it face the direction of the spline.
Thank you! Interchanging the functions did help in fixing the movement. I’ve set the timeline to be 0 to 1, tried to print the alpha value after setting the world location, and it doesn’t seem to be reaching 1. (The values are ranging from 0 to 0.0nnn decimal points)