How to have smooth rotation?
So I have this method:
public void Attract(Rigidbody body) { Vector3 gravityUp = (body.position - transform.position).normalized; Vector3 localUp = body.transform.up;
// Apply downwards gravity to body
body.AddForce(gravityUp * gravity);
// Allign bodies up axis with the centre of planet
body.rotation = Quaternion.FromToRotation(localUp, gravityUp) * body.rotation;
}
And I want the player to smoothly rotate upon entering a planet's gravity to the normal of the planet surface (it works but its not smooth). So far the gravity and player movement is working great, but the transition right now is like a snap. I have tried looking this up all over the place and can't seem to find a working answer. I know that it is the FromToRotation that makes it snap, but I can't seem to do a Lerp or Slerp on it since it gives errors when I do that. Any help is greatly appreciated.
Your answer
Follow this Question
Related Questions
Smooth 360 degree rotation every keypress - C# 0 Answers
My Quaternion.RotateTowards is instant 1 Answer
Smooth look at 0 Answers