Keep forward directon in line with path

I have a somewhat side scrolling game I am working on and I am having a difficult time figuring out how to keep the players forward direction in line with the terrain path as it is not always going the same direction.

Below, if you look at the second image you will see that their forward isnt following the path which should point to those platforms, but it points off to the side.

How can i go about accomplishing this? The current way I am trying is to use a spline and keep the forward direction of the player the same as the spline but it doesn’t seem to work as good as i was hoping. Possibly i am just doing it wrong.



An easy way to align along a path is to LookAt a point slighty ahead on the path:

Vector3 lookat_target = // you just need a point slightly ahead of current position
                        // (however your personal spline/path implementation calculates it)   


I use a spline for movement+facing as well; what’s your code look like? I use 4-point bezier curves, but it’s the same idea - use the difference in curve(@X+1) - curve(@X) to determine the direction at time X.