How do I get a character to follow a certain route?

Hey! I’ve just started exploring the unreal and in the process of creating my first simple game. I’m creating a 2d game with 3d elements and my character already walks only in one plane, but when colliding with objects, the character shifts to the side, due to which his route changes from the original one. Is it possible to force the character to walk only along a certain prescribed route, for example, to bind the character to a spline? If yes, how to do it? If possible, please include an example of how to do this using a blueprint. Thanks a lot!

if you are using physics and you want to avoid the character leaving your 2D motion plane just lock position of the right axis in physics/constraints:

image

if you want to make some object to follow a spline you can just use spline component like this:

to get the position in the spline use this:

time 0 is one end of the spline and time 1 is the other end. Note you can tag constant velocity so the distribution along the spline is even.

you can also create just an actor with a spline and add it a tag like ‘actor with spline’’, in your main actor add a spline component variable and in the begin play you just take the other actors spline and store in your character variable so you can access like this:


this is the spline actor

image

tag it

image

add a spline component variable in your character

store the others spline component so you can access it.

to edit the spline in the scene just select the vertex of the spline in the editor and press ALT and drag the mouse to add new points or edit the tangents.

1 Like

Thank you so much! With your help I found that third person character has movement parameters and there is an option to make character movement constraint to plain and locking X axy worked just as I wanted! Once again thank you so much for help.
image

1 Like