I'm trying to make a simple game with some cubes rotating 90º when the user clicks on them.
I've setup an empty game object, a simple cube nested, an animator, and two animations: RotateClockWise, RotateCounterClockwise.
The idea is: User clicks, the nested cube rotates 90 degrees, then comunicates the new translate component to the wrapper and the wrapper updates its transform (I'm doing this so I can have only two animations). So far, so good.
The thing is that I've noticed that, even though the animation is "90º", once I've clicked enough times, a small offset begins to accumulate and ends up, yeah, rotating 90ºm but starting on 20º, so I got a not aligned cube.
The "dirty" trick I've thought is doing a manual round to the closest quarter on each turn, but that seems something I shouldn't be doing, given how advanced is supossed to be this system.
Any idea of what's going on?
EDIT: This is the math on teh "endAnimation()" function that updates the parent object with the rotation of the child:
float newX = _rootGameObject.transform.rotation.eulerAngles.x + gameObject.transform.localRotation.eulerAngles.x; float newY = _rootGameObject.transform.rotation.eulerAngles.y + gameObject.transform.localRotation.eulerAngles.y; float newZ = _rootGameObject.transform.rotation.eulerAngles.z + gameObject.transform.localRotation.eulerAngles.z; _rootGameObject.transform.rotation = Quaternion.Euler(new Vector3(newX, newY, newZ));