Make Player character follow a specific route?

Is there anyway to make the player character (FPS game) follow a specific route around a map on key press?

So on press he’d move on his own?

I’d also need him to stop/pause at a few places, can this be done?

1 Like

You can use splines if you want it to follow a specific route. Just set the position and rotation of the character to the current spline path point. In short: yes, everything you want is possible.
Here’s an example I did for a tower defense game:


Im happy to explain everything if theres someting unclear :slight_smile:

1 Like

Wow that’s pretty cool looking!

But it seems pretty difficult to do and for an idiot like me to understand!

Is there a step by step anywhere on how to achieve this, I don’t understand the variables used and even where this bp would go, is it part of the level bp?

I’d really appreciate some help!

Thanks for the reply!

Actually its quite simple :slight_smile:

First you create a blueprint(lets call it BP_Spline) and add a spline component. Then simply drop it in the level and select the white rectangle and hold ALT while dragging the white rectangle away from its initial location. That will generate a new point in the spline and connect both of them.
Use this to build your path.

Once that is done, create a BP_Spline variable inside your desired player/AI/whatever controller blueprint and set it to instance editable. This allows you to set the variable to the path you just created inside the level as you can select it in the details tab.

Now for the movement: Create a float variable, lets call it SplineDistance. Every tick you want to move the actor along the spline, you have to increase the value of this variable until the SplineDistance is greater/equal to the spline length(Get Spline Length)
With this SplineDistance variable, you can query the world position(Get Location at Distance Along Spline) and rotation(Get Rotation at Distance Along Spline) of any given distance along the spline. Simply set the actor location/rotation to the outputs of these two functions.

Once everything works, you should be able to achieve your goals. If you need a finished example, I post one for you. :wink:

If you can post a finished example please do, it’s really interesting and I appreciate your help!

Would it also be possible to pause player movement at specific points along the spline?

Of course, simply don’t increase the SplineDistance variable.

I added a small zip containing a pawn, a controller and a spline blueprint.

Simply place the pawn and a spline inside your level, set the pawns spline variable to the spline actor and it should work once you start the game.

I really appreciate that, thank you!

Thank you so much TriNityGER for sharing the code. Its working. Got the basic idea how to move something along a spline. Helped a lot.


Love the work done so far. I’m completely new to UE4 too. I’m trying to get an NPC character (roadside pedestrian) to follow a specific path that I made using a spline.
Currently I have them set up using a simple ‘AI MoveTo’ between 2 target points.

Is there any way of adapting what you’ve done above and having it apply to an NPC character and trigger automatically?

I would really appreciate any help.