Endless runner. Spline paths

Hello everyone! I’m trying to create an endless runner. For now, I have constraints for changing lines, but these things work when you have only strait forward tiles. But I want to have slightly curved floor tiles, too without getting the player out of the lane, like in Subway Surfers or Sonic Boom 2.
The only solution which I could think of was to do it with a spline. I have seen some tutorials and I think I would be able to make it possible to let the player move left and right along the spline, but the problem is since the endless runner game has a randomly generated course there cannot be one long spline along the course, but many short splines. In fact, one spline for each floor tile and the problem is that I don’t know how to connect them. I hope someone can help me solving this problem or knows probably an even easier solution :slight_smile:

1 Like

I don’t quite understand your question but a few days ago I came across a very good tutorial for making an endless runner on unreal engine. Creating a MOBILE Endless Runner Platformer Game With Unreal Engine 4 - For Beginners! - YouTube

Hopefully, you will find your answer in this tutorial series.

Can you give us a piccy? To show how you might need a spline?

Ye sure. The first and third pictures show the 3 paths of splines on 2 different BP( because runner like games need to have some different tiles). The main target is to learn my character that he can change his path only on these splines. But there are 2 problems. 1- I cant check on which spline my character, so I can only teleport from the first spline to third and skip middle one. But the second problem is that the solution of the first problem goes only for not randomized BP and goes only for one BP, not the multiple with multiple splines. I know that I can make paths with preset values, but I still don’t want to have straight forward path.

Thanks a lot, I did my current runner game with this guide, but how you can see in the 3-rd lesson (Floor Tile Setup - #3 Creating A MOBILE Endless Runner Unreal Engine 4 - YouTube) he makes a straight forward path, but i would like to make it a slightly curved floor tiles. But still, this is an amazing guide, thanks)

Ok, I get it. You mean curved, like around a smooth corner…

Yes, I think it’s possible with splines. But don’t lock the player on the spline, otherwise you’ll always have a ‘jump’ when they change tiles.

Much better to use tick to move them onto the spline when they get a bit off course. The amount you set the interp speed of the vinterp will tell the system how quickly to correct the player.

You don’t need to get a perfect ( or any ) join on the splines, just having splines on the tiles is ok. When you change tiles, just change the spline you’re using to correct the player.

My idea works in principle. Straight tile:

corner tile ( you can make it more gentle, more points etc ):

Here’s the action ( I’m only pressing W ):

297630-corner.gif

Gimme a while to tidy up the code and I’ll put it here…

So, this is it. There’s just one tile BP:

Almost no code:

The variables ( TilePercent, Spline, TileSplineLength ) are in the character.

Not saying this is the most efficent way to do this, but in the character I have ( 3rd time lucky ):

Tell me how you do…

Here’s the BP as a text file also ( you just open it in notepad and copy paste the whole thing into the event graph ).

[link text][4]

1 Like

Sorry for long answers, that is my first question in UE community, so it needs to be moderated)
I didn’t understand everything in BP (just didn’t saw some things and don’t know how they work), but it actually WORKED!!! Thanks a lot! I will spend some time learning how everything in it works) but still, that is amazing! Thanks a lot, once again)

And one last question) I tried to create 3 lines with this code with multiply ways.

  1. I tried to get the Vector location and rotation of Spline and change it in the Tile space for changing actor location(like 3 rows).
  2. Also, tried to get character Right vector and locate with Y on this way, but that also doesn’t work
  3. Tried to make a line rotator for a character with predefined values and changing Y with X rotation(because with your code that became possible, thanks again :D), but that doesn’t work, probably I have missed something in BP, but the result of setting character location on splines looks best for now (instead of teleporting which you noticed earlier).

Could you please give me advice on which direction I need to think?

1 Like

Hi - You should be able to make the character go any way you want by just making different shape tiles, but…

If you are trying to set the character to the rotation of the spline ( not just left and right but leaning also ), that would require a pretty major mod to the code.

When you are setting the character rotation to the spline rotation, you have the option to use ‘local space’ or ‘world space’. I’d try both, you might find one works better than the other…

1 Like

When I try to implement the blueprint as shown in the above picture, my character gets stuck at the starting point of the spline. I don’t know whether I have done this in the wrong way or not. I know this one us old but I need to an help.

Are you looking for the same thing? Tiles with a spline, and corners?

I think I have a better way…

That’s the whole thing…

2 Likes

Thank you, bro you saved my time. Tbh I don’t know how it works but it worked well in my game.
But I have 2 questions,

  1. What is the use of the last point variable in event begin play?
  2. What is the At End function do, I can’t find it in right-click(I am started learning UE a month ago so I don’t know is a built-in function or not)?[I haven’t set the enabled value after set control rotation due to that but it works fine so far]

Once again Thank you for the help I struggled for more than a week :smiling_face_with_tear:

Hey, it wouldn’t let me post the ‘at end’ function yesterday

Thanks for the reply

1 Like

You might want to increase that tolerance to 5, say…

image
how did you make the function without executing pin?