Moving along multiple splines (branching pathing). Aka, help me set up a movement system!

Hello everyone. I’m currently working on a sidescroller ( and have run into some problems.

Namely, I need to figure out a proper movement system. Now, I already have a basic spline movement system semi done, but I am unsure if this will really work with what I had in mind. Case in point, please see this image:

This is what I want to achieve - basically, the problem is that with the spline component, I can only move along one path, and cannot change into a different path… What I would need is a constrained movement system, but with the freedom to “branch off” the beaten path at certain key locations. I would use the wasd or arrow or dpad strictly for direction control, and other buttons for jump/dash/whatever.

I hope this makes sense.

Is something like this possible? What would be the best way to implement a system like this? A modified free movement system? Any and all advice is welcome, I am really stuck here.

Feeling inspired to find a solution to this, I decided to make a project to figure it out, and have come up with a proof of concept solution. Meaning, it could be cleaner or have unwanted functionality, but it basically works.

Basically a spline is added to a Spline Actor and is one direction only. When the spline reaches what is supposed to be a branching point, it just stops there and two or more new Spline Actors are added to the editor. A (T)Map is then used to determine which Spline Actor is referenced in which direction.
So the Map key is an Enum (Stop, up, down, left, right) and the value is a reference to the Spline Actor.
(In case you don’t know, by selecting a variable and checking “instance Editable”, you can in the editor select the Spline Actor and then allow that instance to have a reference to other instances.)

So the player makes an input which is saved as a direction, the Pawn gets a reference to the next Spline Actor and starts following that instead.

As some additional things, I created a Default Direction variable to the Spline Actor so that if the player makes no input, the Pawn just continues in the default direction.
The Stop Enum is there if the pawn should stop at a fork, waiting for player input, instead of continuing on the default path.

It’s not much code but had to take 3 screenshots.

A few things to note:
-The way the pawn is moved along the spline is by resetting a float when a new spline is to be moved along, then adding the tick float to it every frame. This is just for me to get the pawn to move along the spline and may not be what you are doing.
-I ended up using 3 different enums for the various directions (directions [Up, Down, Left, Right], Spline Actor Directions[Stop, Up, Down, Left, Right], Player input[None, Up, Down, Left, Right]) and can probably be replaced with a single one.
-The way that it is determined if the pawn has actually reached the end of a spline is by comparing the splines length with the move time, with some tolerance. Maybe that’s not good enough.

  • In the editor screenshot, the arrows shows the splines and Spline Actors have been slightly separated to show that there are actually several actors, not several splines in one actor. Though thinking about it now, that’s probably possible too and would be very similar to the current solution.

Thank you! Seriously!

I’ll check it all out in the next few days and report back!

gives up waiting on report :wink:

Oh haha, sorry!

I figured it was way easier to simply get rid of the spline movement, and let the actor move freely - and then place invisible walls to guide the player in the right direction. In any case this project is on hold at this time - I am working on something quite a bit different :smiley:

Which type are Linked Spline Actors