Rotation Around the Y Axis

I am trying to write some code to rotate and object around the y-axis. Every time I run the code, the
cubeTransform.localRotation.eulerAngles.y, eventually ends up at 0 and resets the transform to 0 and I cannot move with the mouse.The code is running in the update function. Help!

float newRotation = Input.GetAxis(“MouseX”) * cubeTransform.localRotation.eulerAngles.y * rotationSpeed * Time.deltaTime;
cubeTransform.localRotation = Quaternion.Euler(0, newRotation, 0);

FYI…I have a public reference to the Transform of the object called “cubeTransform”. Also, the code seems to work with cubeTransform.Rotate(0, newRotation, 0) until I get to zero in the y transform rotation. Hmm…

It’s always best to use code tags when posting code.

And as far as rotating objects, I find it better to not rely on euler angles as they’re honestly only useful when viewing rotations, rather than applying them. In your code, your code is only setting the rotation, rather than adding to it.

It’s quite likely that the rotation you’re producing is too small to perceive too.

When rotating around an axis, Quaternion.AngleAxis does a better job:

float delta = Input.GetAxis("MouseX") * rotationSpeed * Time.DeltaTime;
cubeTransform.rotation = Quaternion.AngleAxis(delta, cubeTransform.up);

This will rotate an objet around it’s local y-axis by means of moving them mouse left/right.