- Home /
Rotation 90.0001 and 1.001719 bugs!
// flip according to direction
if(isHorizontal)
yAxis += 90;
else {
if (xAxis == 90)
xAxis = 0;
else
xAxis = 90;
}
// round the whole rotation
iTween.RotateTo(resource, new Vector3(Mathf.Floor(xAxis), Mathf.Floor(yAxis), 0), ANIMATION_TIME);
The code is working fine except for 1 problem, I am getting the rotation angle at 90.00000001 and 1.001719.
Now I don't think the 90.000001 degrees is affecting the outcome but the 1.001719 is affecting the whole object as it is not perfectly aligned anymore.
Is there a way to get the exact values?
The code will always return an integer value so is there a way I can tell it to make a rotation angle with integer values?
I am not familiar with iTween, but is there a callback that you can write when the tween is finished? If there was, you could overwrite the final rotation with the angle you want.
The 1.001719 value is troubling and an indication of a bug somewhere. As @$$anonymous$$A mentions, the 90.000000001 is an expected result of using floating point numbers. As to @raimon.massanet's suggestion, iTween does have callbacks. If you decide to address your problems by explicitly setting eulerAngles, be sure to assign them all at once by assigning a Vector3. Don't address them individually.
Answer by DaveA · Oct 11, 2013 at 02:33 PM
No, welcome to the world of floating point numbers. See http://docs.unity3d.com/Documentation/ScriptReference/Mathf.Epsilon.html
can't I set it manually? like transform.rotation = quaternionangle or something like that? or transform.rotation.x = something
I am rotating the object vertically and horizontally so its just 90 degrees each Can I somehow use the vector.up and so one ?
Your answer
Follow this Question
Related Questions
Flip over an object (smooth transition) 3 Answers
How to always rotate clockwise 1 Answer
Keep objects current rotation, with Input Mouse X 0 Answers
Why is this rotation acting odd? 0 Answers
LookRotation is upside down? 1 Answer