How to attach a pawn to a Spline Blueprint

Hi guys

Yesterday saw this tutorial that shows how to create a road using the construct script.

That is very good and works perfectly.

Only I want to implement other features to it and I am in doubt about how to do this. And I need help.

Features list:

  • Ability to attach the pawn (player) to follow the spline
  • Being able to follow the path, but the possibility to freely look around.
  • Possibility of applying gravity in pawn
  • Ability to change the speed that the pawn makes its way

I need these options, because I have to do a roller coaster, tried using a plugin, but it only works in older versions of UE4 (Version 4.6.1).

And I want to reproduce this effect, but using the Gear VR.

Thanks.

Attaching to a Spline involves setting the location of your pawn to a specific location along the spline (bear with me). To get a location on a spline you can use one of two methods: Distance or Time.

Time of a spline is 0 to 1 from the start to the end. So .5 time on a spline is halfway.

Distance is the actual length of the spline in units.

So if you wanted to move down a spline then every tick you could set yourself some distance or time down the spline.

This example increments a distance tracking float based on a speed float. At the end I find out where in the world that distance down the spline is and i use it to set my actor/pawns location:

You could use Time if you want to always go from beginning to end relatively.

On top of all of this you can get the tangent at any time/distance to perhaps change your acceleration/velocity so you move slower up hill and speed up going down hill.

None of this takes advantage of the built in physics systems but would make an easy to handle rollercoaster.