- Home /
change the rotation of an object by rounding the angle
i want to know how to safely round a quanterion value.
basically i want to make a rotational change but only by whole number degrees
I figured i could do
selection.RotateAround(Camera.main.transform.forward, rotate_speed *Time.deltaTime);
selection.rotation = new Vector3(Mathf.Round(selection.rotation.x), selection.rotation.y, selection.rotation.z);
to round the x rotation. however i can't because its a quanternion and messing with the values of a quanterion manually isn't supposed to be a good idea. So how can i convert a quanternion to a euler so i can round that euler and then convert that euler to a quaternion
http://answers.unity3d.com/questions/183603/convert-quaternion-to-eulerangles.html
Sorry I can't be more precise, you have to have Euler angles.
Answer by MountDoomTeam · Oct 13, 2012 at 03:33 AM
youhave the mathematics pretty good, also be aware of floor and ceil rounding options,
Try this-
myEuler = selection.transform.localEulerAngles;
myEuler = selection.transform.eulerAngles; and then use that vector three instead.
Your answer

Follow this Question
Related Questions
Camera Script - RtS style, rotation issues 0 Answers
Problems with rotation script. 2 Answers
Z rotation locks to certain value randomly? 0 Answers
door script problems 2 Answers
Make ball flip around cube... 0 Answers