Hey there.
Suppose there is a sphere currently rotated at random.How can i interpolate the sphere’s current rotation so it’s Up vector rotates and stays at the worlds up vector(Vector3.up).So i tried doing it like so:
private void Update()
{
transform.rotation = Quaternion.Lerp(transform.rotation, transform.rotation * Quaternion.AngleAxis(90, Vector3.up), Time.deltaTime * 1);
}
But that rotates the sphere AROUND the Y axis and does not return it to the world’s up vector.With that said i also tried:
private Quaternion mStartingRotation = Quaternion.identity;
private void Start()
{
mStartingRotation = transform.rotation;
}
private void Update()
{
transform.rotation = Quaternion.Lerp(transform.rotation, mStartingRotation * Quaternion.AngleAxis(90, Vector3.up), Time.deltaTime * 1);
}
That also produces the same result as the last code. So what i am basically trying to achieve is on the following to images:
Can somebody help me out