Changing Spline

Hello, I’m working on a 3D Sidescroller game and I found out that moving a character along a spline is more interesting than constraining it on specific axis.
I managed to follow a tutorial that shows how to move my actor along a spline but I can’t figure out how to make the character change to another spline once it reaches the end key of the previous one.

Hey @TESTGAMING5001

may I ask how you move along the spline?

To check if you are at the end of the spline:

  • Compare your current transform to the transform of the last spline point:
  • Compare your distance on the spline to the spline length:

    Here I move via the distance along the spline. If the distance equals the spline length I set the distance to 0 to start at the beginning (continous movement on the spline). If you are using the distance you could also compare distance and spline length to then switch the spline.

@L1z4rD89

Saw this on a tutorial. From what I understand it that it pretty much scans for the closest direction towards the spline, Nomalises the vector, multiplies it by a distance Variable that works like a scanner to correct pathing, multiplies the previous value by the z vector from “Get Controll Rotation” and “Get Forward Vector”, I don’t understand exactly why we add the Actor Location Vector to that. Anyway, All of this then is connected to the “World Direction” Socket in “Add Movement Input”.
Sorry if I sound so noob I’ve just started learning developping games, I have good knowledge in other stuff but very new in the Programming&Scripting aspect.


Okay, you could now use your Distance to compare it to the SplineLength or compare FindLocationClosestToWorldLocation to GetLocationAtSplinePoint for the last SplinePoint.
UE5_CharacterAlongSpline.zip (838.5 KB)

1 Like

Thank you so much, I’ll make sure to try to understand the logic, but there are 2 more things I want to Know, 1st is the reason the character is teleporting to the next Spline, is it because the point of reference is the beginning of 1st point in the next Spline? and 2nd Is there a way to make the character walk to the next spline after reaching the last one, and walk back from the current one to previous one?

Yes, the character teleports to the next spline to stay on the next spline, here the point of reference is the first point of the next spline. Moving between the two splines should be possible (maybe you have to adjust the tolerances for the EQUAL nodes at the bottom)
CharacterAlongSpline_With_Transit.zip (906.3 KB)