Why two "RotateAround" calls around transform.right and transform.up results in slight rotations also in the Z axis?

Hi,

I don’t know why these two consecutive rotateAround calls give me small unwanted rotations in the Z axis:

transform.RotateAround (objetivo.position, objetivo.transform.right, input_eje_y);
transform.RotateAround (objetivo.position, objetivo.transform.up, input_eje_x);

if I comment out any of them, i get the correct rotation around the proper axis. Can somebody please help me to understand what’s going on here?

BIG thanks in advance!

1 Answer

1

Im guessing that something about the way Unity implements the total rotation involves a simplification of the two rotations, which involves floating point numbers.

Floating point numbers are notorious for being inaccurate, see here and here.

As for preventing/correcting this problem, I think there are many different solutions, but a simple one might be to convert your angle to an int before rotating.

Good luck!