- Home /
Set rotation of a transform
Hi all!
I want to rotate a transform to a specific angle, not add to the existing rotation. Currently, on every frame, I am doing:
transform.Rotate(Vector3.up * rotation);
What I expect is a smooth transition over time as "rotation" changes, however the object is spinning like crazy!
Do I need to use a method to grab the current rotation and then offset by that? Or is there a method that will allow me to directly set the rotation?
Thanks!
You should use Time.deltaTime, since that line of code is not framerate-independent and will vary as the framerate varies.
I know what I'm doing with the angle itself, my question is about how to set the absolute rotation of the object, not just adjust the rotation.
Answer by Poisoned-iV · Nov 05, 2016 at 08:58 AM
You can also achieve the same thing as from EulerAngles by:
t.Rotate (Vector3.up, x);
where x is the degrees of rotation you want.