Move a character along a spline while having movement left/right

Hi, I’m trying to create a situation where the player runs on a given spline path at a changeable speed but can maneuver from left to right to avoid obstacles. Right now I can get the character to follow a “path” spline with GetLocation at Distance Along Spline function, somone mentioned using offset on the y-axis, but I can’t figure out how to set up the blueprint for that.

Any tips and help? Thanks a lot!

Hi Dorisgao,

I think the problem you’re running into is that your characters location is being set every frame to be on the spline.

So I think a solution would be to have the ‘scene root’ follow the spline (like it already is) and change the location for certain objects in your pawn/character.

I tested this for just the camera, but It should work the same for a hierarchy of parent/child objects. (A mesh with a springarm child with a camera child for example)

Welcome to the forums, let us know if you have any more questions about this!


Continuing the discussion from Move a character along a spline while having movement left/right:

Hi Astrotronic,

Thanks, that is very helpful! I got it working now. One problem is that it will make a sharp transition to the

left or right. Is lerp the correct function to use here in order to make a smooth transition?I had set up the blueprint like this now. Thank you again!!!

Glad to hear it!

Making it smooth is naturally the next step. :slight_smile:

FInterpTo is the node you’re looking for.

1 Like

You could also have a look at this, a little different, but maybe helpful :slight_smile: (881.1 KB)

1 Like