Movement/rotation along a spline on the x axis

A few people and I are working on a prototype for an endless runner type game and I’m having trouble with some of the controls. Basically, we need a flying character with a free z/y (the whole vertical plane) movement, but a forced forward speed. That much is going pretty well, but we’d also like the path the character takes to be roller-coaster like, with turns that just don’t work too well with the way the fixed third person camera and the forward movement are set…

My solution was to try to set the character rotation along a spline so the x axis/vector always follow the curve of the path we want it to take, but I’m having trouble setting this up. I managed to make a spline actor and place it how I wanted in the map, but I can’t get the character to actually follow it. The character needs to be able to fly away from the spline and only have it’s orientation and forward movement directed by it.

I’ve tried following this tutorial as a base, but I can’t seem to get it to work (not even the first step in blueprints that places the player character on the spline): Tutorial: Blueprint Spline locked sidescroller (e.g. Klonoa / Pandemonium style game) - Programming & Scripting - Unreal Engine Forums

I’m quite new to blueprint and I’m especially confused about the “distance along spline” variable that I see popping in there since it doesn’t exist by itself in blueprint… Do I need to create a new float and name it that way? Will Unreal really know what to do with that thing event if it’s not really linked to anything???

distanceAlongSpline is a custom float that controls the function GetWorldLocationAtDistanceAlongSpline().

distanceAlongSpline is controlled by the inputAxisMoveRight event, so the value is updated by the controller input.

as for your specific problem, you could get 2 points on the spline, X and X+5.
you can findLookAtRotation between these to get the rotation you need, then you can add a playerYoffset variable to the rotations getRightVector and add a playerZoffset variable to the rotations getUpVector, giving you the position of your character offset from the position of the point on the spline, facing the direction the spline is moving in.

for an endless runner, you can let the player control the offset variables, while the distanceAlongSpline variable is animated to go faster and faster as the game progresses.

if you want the game to be endless, you will need to transition between splines, resetting the distanceAlongSpline to 0 every time you reach a new spline, and possibly recentering the world coordinates so they don’t overflow.

i haven’t tried any of this, but it sounds like it should work.