Object rotation snap..

Hi,

I’ve been using Unity for some time and something that’s bothered me although i’ve always just worked around it is this:

When i hold ctrl whilst rotating an object, it snaps to slightly off values - for example if i rotate to 90 degrees using the crtl key it snaps to 89.997 or 90.003 instead of exactly 90 degrees.

Is this a bug of the specific version of Unity i’m using (5.5.0f3) ?

Anyone? Is this standard behaviour across all versions?

Thanks.

For me it snaps to 90.00001 in 2017.1. I think it’s a floating-point issue that’s inherent in Unity, but I’m not sure.

Yeah i figured it’s some floating point math related thing. Can anybody confirm if it’s always been this way in Unity?

Not a huge issue, but i’m kinda OCD with values and when snapping rotation i prefer/hope for it to behave in the expected way…

Weird that i can’t find any info or mention of this elsewhere, hence why i’ve ended up posting here about it.

As far as I understand it, internally Unity stores rotations as Quaternions. So when using the editor, it has to keep converting back and forth between euler and quaternions when updating values. So floating point errors creep in.

I’m not sure there’s much that can be done about it. I get this when cloning objects too.

Yeah i get that the math behind it is finnicky, i just think it’d be better to not expose that sort of behaviour to the user, within the editor… Every other 3d app i’ve used snaps to 90 degrees and i’m sure most of them deal with Quaternions in one form or another…

For what it’s worth, i find positioning really annoying also. For example you move an object with ctrl held down to snap to the grid, however if the object is a child of another object, the position values are relative to the overall scale of the parent object. So say you’re snapping the object in increments of 1 world unit on the x axis, the position value often reads something like 1.33 etc. Really annoying, although i’m not sure if there’s a way to display only global positions, or even positions that are still relative to the parent object but shown in world/global units rather than this weird proportional thing. It would just make sense for the behaviour to be consistent with other apps really.