# Endless runner. Spline paths

**URL:** <https://forums.unrealengine.com/t/endless-runner-spline-paths/461999>\
**Category:** Blueprint\
**Tags:** endless-runner, unreal-engine, path, Spline, Blueprint, question\
**Created:** [March 2, 2020, 11:40am UTC](https://forums.unrealengine.com/t/endless-runner-spline-paths/461999 "2020-03-02T11:40:30Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![R3DMyst89](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/r3dmyst89/32/475719_2.png) [@R3DMyst89](https://forums.unrealengine.com/u/R3DMyst89)\
**Post date:** [April 4, 2022, 7:26pm UTC](https://forums.unrealengine.com/t/endless-runner-spline-paths/461999/42 "2022-04-04T19:26:42Z")

</div>

yeah, i got it… totally my mistake: in the “at end” function i used the “player location” variable instead of the “last point” variable, it works AB-SO-LUTELY perfect now 😄

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [April 4, 2022, 7:29pm UTC](https://forums.unrealengine.com/t/endless-runner-spline-paths/461999/43 "2022-04-04T19:29:01Z")

</div>

FAB 😃

( and a bit more text otherwise it won’t let me post )

---

<div class="post-metadata">

**Author:** ![R3DMyst89](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/r3dmyst89/32/475719_2.png) [@R3DMyst89](https://forums.unrealengine.com/u/R3DMyst89)\
**Post date:** [April 15, 2022, 5:44pm UTC](https://forums.unrealengine.com/t/endless-runner-spline-paths/461999/44 "2022-04-15T17:44:29Z")

</div>

Sorry to bother you once more (or more than once depending on how this goes 🤣 ) but how would i tackle the whole switching lanes thing and more specifically, the switching lanes after a turn (i would say a turn that is 45 degrees or more) has taken place? Once you turn a corner, you are technically no longer switching lanes on the Y axis but on the X axis, i’ve tried many things but I really have no clue of what i’m doing

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [April 15, 2022, 6:49pm UTC](https://forums.unrealengine.com/t/endless-runner-spline-paths/461999/45 "2022-04-15T18:49:50Z")

</div>

You’ve probably noticed that this system works for corners already, right? It’s because the X and Y stuff is local to the tile. We’re not talking about the world.

Two lanes works in exactly the same way, but you have two splines, and you have to decide which one to ‘suck’ the player to, depending on which lanes they’re in.

---

<div class="post-metadata">

**Author:** ![R3DMyst89](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/r3dmyst89/32/475719_2.png) [@R3DMyst89](https://forums.unrealengine.com/u/R3DMyst89)\
**Post date:** [April 15, 2022, 7:12pm UTC](https://forums.unrealengine.com/t/endless-runner-spline-paths/461999/46 "2022-04-15T19:12:52Z")

</div>

right, that makes sense. You’d just add more splines to the tiles and go from there, right? But since the player movement isn’t really “snapping”, the player just casually “jogs” to the next lane instead of “snapping” to the next lane, the way it’s typically done in an endless runner game. So that’s totally fine but then the question would be, how can i make my character “suck” or “snap” to the next lane? I’m at a total loss here.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [April 15, 2022, 7:21pm UTC](https://forums.unrealengine.com/t/endless-runner-spline-paths/461999/47 "2022-04-15T19:21:43Z")

</div>

That code ( up there ), it already does it. Using the ‘nearest location on spline’ node.

All you have to do, is change the spline reference to your other spline.

---

<div class="post-metadata">

**Author:** ![R3DMyst89](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/r3dmyst89/32/475719_2.png) [@R3DMyst89](https://forums.unrealengine.com/u/R3DMyst89)\
**Post date:** [April 15, 2022, 8:11pm UTC](https://forums.unrealengine.com/t/endless-runner-spline-paths/461999/48 "2022-04-15T20:11:22Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/5/5/955dd3ebb50017e303cb1d8f628042405735a5a9.png)

I probably did this all wrong, but this is what I assumed you meant… I have no idea

---

<div class="post-metadata">

**Author:** ![R3DMyst89](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/r3dmyst89/32/475719_2.png) [@R3DMyst89](https://forums.unrealengine.com/u/R3DMyst89)\
**Post date:** [April 15, 2022, 8:12pm UTC](https://forums.unrealengine.com/t/endless-runner-spline-paths/461999/49 "2022-04-15T20:12:09Z")

</div>

so the event tick node is on the center spline and D would be the right spline

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [April 15, 2022, 8:26pm UTC](https://forums.unrealengine.com/t/endless-runner-spline-paths/461999/50 "2022-04-15T20:26:06Z")

</div>

No quite. It’s the _exact_ code from above. All you have to do is set the spline ref to spline1 or spline2. The code does the rest.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [April 15, 2022, 8:27pm UTC](https://forums.unrealengine.com/t/endless-runner-spline-paths/461999/51 "2022-04-15T20:27:54Z")

</div>

Just change this

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/2/c/d2cebddf4bce6e085d4a6e6996d03c8db16198e1.jpeg)

You either set it to the left or right spline.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [April 15, 2022, 8:34pm UTC](https://forums.unrealengine.com/t/endless-runner-spline-paths/461999/52 "2022-04-15T20:34:04Z")

</div>

Sorry, it’s late, I’m not being very clear.

You already have the code to follow one spline, but instead of putting the left or right spline reference in there, you put another spline variable in, ‘spline to follow’.

When you want to change lanes, all you have to do is change the variable from left to right spline.

---

<div class="post-metadata">

**Author:** ![R3DMyst89](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/r3dmyst89/32/475719_2.png) [@R3DMyst89](https://forums.unrealengine.com/u/R3DMyst89)\
**Post date:** [April 15, 2022, 8:41pm UTC](https://forums.unrealengine.com/t/endless-runner-spline-paths/461999/53 "2022-04-15T20:41:01Z")

</div>

Right, okay. You mention putting another spline variable in ‘spline to follow’… you lost me there. I’m so sorry, it’s probably a lot easier than I think it is 😅

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [April 16, 2022, 4:49pm UTC](https://forums.unrealengine.com/t/endless-runner-spline-paths/461999/54 "2022-04-16T16:49:30Z")

</div>

I will come back to you later today ( sorry, very busy )…

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [April 16, 2022, 6:52pm UTC](https://forums.unrealengine.com/t/endless-runner-spline-paths/461999/55 "2022-04-16T18:52:28Z")

</div>

My original idea was this

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/7/7/b773d54a4786a5117b9f6d152e6985a1ac0c460d.png)

As you can see, very easy to change splines.

The problem is, when a new tile spawns, it doesn’t know about this.

So you need a separate actor to store the current spline in. ( more in a mo ).

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [April 16, 2022, 7:03pm UTC](https://forums.unrealengine.com/t/endless-runner-spline-paths/461999/56 "2022-04-16T19:03:30Z")

</div>

So we have a ‘spline chooser’ blueprint, you drop it in the level, and the only code it has is

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/6/c/96cdc289b66d828a3cc13e2301c6a98119d7e7a3.png)

Then, the tiles do this to setup the variable

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/6/9/269203f44460e41ac40bf404c23fbf4073a3d7a3.png)

On begin play, the tile finds the chooser, and figures out which spline to use. When you swap lanes, the tile tells the chooser, and the next tile knows about this when it’s spawned.

boom.

---

<div class="post-metadata">

**Author:** ![R3DMyst89](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/r3dmyst89/32/475719_2.png) [@R3DMyst89](https://forums.unrealengine.com/u/R3DMyst89)\
**Post date:** [April 18, 2022, 10:45pm UTC](https://forums.unrealengine.com/t/endless-runner-spline-paths/461999/57 "2022-04-18T22:45:50Z")

</div>

well, not sure what I’m doing wrong here but this does **not** work either… (so it’s safe to assume i did something wrong 🤣 )  
got the “Spline Chooser” Blueprint in the level as you can see:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/8/3/e833dd1a14b2ac27c5581206b548c75cade74fdb.jpeg)

Got the code the exact same as you can see here:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/f/0/4f04eaab59a6acc281e7ed66b68c716b44a9789e.png)

and here as well:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/0/8/908ea1bc6744463a3b7b7178fddc9d96f038457d.png)

in the video below you can see that the player get’s stuck on the center spline (it doesn’t matter in this case, if i replace or turn that spline off, it’ll just get stuck on the left or right spline, depending on which spline i set it to) and as you can see as well, the player get’s stuck for about a second before it’s starts moving again and is unable to move left or right.

[https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/4/d/94d3030ced3b49f76b12a1eb1480cb5cb1f778db.mp4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/4/d/94d3030ced3b49f76b12a1eb1480cb5cb1f778db.mp4)

i have no idea what i did wrong but i cant imagine it being THIS hard… 😅

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [April 19, 2022, 6:59am UTC](https://forums.unrealengine.com/t/endless-runner-spline-paths/461999/58 "2022-04-19T06:59:29Z")

</div>

This variable should be ‘spline in use’

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/b/d/6bd382b5c2fcf8a350c7fff29b88b1f7ad190452.jpeg)

Do you have that?

---

<div class="post-metadata">

**Author:** ![R3DMyst89](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/r3dmyst89/32/475719_2.png) [@R3DMyst89](https://forums.unrealengine.com/u/R3DMyst89)\
**Post date:** [April 19, 2022, 1:26pm UTC](https://forums.unrealengine.com/t/endless-runner-spline-paths/461999/59 "2022-04-19T13:26:27Z")

</div>

I did not, as i didnt know (i shouldve known 🤦 ) but i changed it and now it defaults to the right spline and the exact same thing happens as you can see in the video above.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [April 19, 2022, 1:29pm UTC](https://forums.unrealengine.com/t/endless-runner-spline-paths/461999/60 "2022-04-19T13:29:53Z")

</div>

You have 3 splines. If you want to do it with 3 splines, you have to do the same thing I have done here, but with 3, of course.

You’re moving the goalposts… 😉

Or take out the code for centering on the middle spline for testing.

---

<div class="post-metadata">

**Author:** ![R3DMyst89](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/r3dmyst89/32/475719_2.png) [@R3DMyst89](https://forums.unrealengine.com/u/R3DMyst89)\
**Post date:** [April 19, 2022, 1:35pm UTC](https://forums.unrealengine.com/t/endless-runner-spline-paths/461999/61 "2022-04-19T13:35:51Z")

</div>

the only part where the center spline is in a piece of code is right here:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/e/9/5e981d4f22b45e5252eb57cb4dd10aa3cde77d46.png)

and that part isn’t connected to anything, should it be? (with the spline in use for the time being)

[Previous page](https://forums.unrealengine.com/t/endless-runner-spline-paths/461999.md?page=2)

[Next page](https://forums.unrealengine.com/t/endless-runner-spline-paths/461999.md?page=4)
