I'm making a skateboarding prototype in Unity, and like in skate 3, I'd like the player to sort of "align" gradually to their predicted landing slope. I've written the code that gets the predicted point at which the player will land, but actually rotating the player to it is proving difficult.
How can I make it so the player (by default) has their upward orientation gradually adjusted for a smooth landing, but still allow the player to spin in-air?
I've tried using LookRotation with the player's forward direction, and the predicted hit normal as the up, calculated when the player leaves the ground. This results in the player being unable to spin midair, and also tends to flip/spin out randomly.
Here's the code I'm using: (executed the frame they leave the ground)
predictedLandingRotation = Quaternion.FromToRotation(transform.up, predictedLandingInfo.normal);
In air, I do this every frame:
transform.rotation = predictedLandingRotation;
(I typed this on mobile so sorry if the formatting is a bit funky)