I’ve been trying to solve this for a while now and am at the end of my wits. It’s about time I ask the community for help on this one.
I’m making a side-scrolling game that takes the player through 3d spaces. That is to say, there is only left and right movement, but the player will be following a path. Think of it like a car that has a go-pro mounted to a self stick taped to the side of it.
I’ve hit a bit of a snag with my way-point system. I want my controller to be robust and able to handle all sorts of orientations and positions. The player himself will be aligned to the ground normal, so on inclines, the player’s up axis will not be pointing along the world’s up axis.
Way points on flat surfaces are not an issue. The controller works perfectly on those. It’s when the player is on an incline that the waypoint orientation begins to fail. I’ve attached a picture to showcase the problem.
The controller only rotates the object during one frame, when the player has passed the current Nav Point. My process has been to get the objects up direction by raycasting onto a plane that is a child object of the player/object (this way point code I plan to use on multiple objects). From there, I use LookAt to rotate the object to look at the next nav point, then I use FromToRotation to align the player/object’s up transform to the normal I had stored before.
It comes close… but it’s not precise enough! At longer distances, the failure begins to show big time. The player could be several meters away from the next nav point. Here’s a sloppy example. When I move to the Nav Point, the rotation happens on the previously shown incline. The forward axis of the player is not lined up with the next nav point.
I’m trying to find a way to rotate the player/object along its up transform and point at the next nav point, and it all needs to happen in a single frame. I’m sure there is some math that can accomplish this, and I’ve been trying to figure out a way to make it happen. I’m just at a total loss now and quite frustrated as this is the last bit of code I need to finish my gameplay controller.
Any help would be appreciated! I can find a million threads and questions about looking at an object or locking the y rotation of an object with LookAt, but all of those fail if the objects isn’t aligned with the world axis’s!
EDIT:
The nav points will all be located at 0 on the y axis. I can’t just align the nav points to where the player will be facing, because the world will have various platforms to jump on/the character can jump. They aren’t locked to the ground.

