[Solved] Problem with rotation script using Unity Script

edited in Questions and Answers
The script line below is supposed to rotate my object but instead it rotates only the handles of the objects. Any idea why it does this and thanks for any help in advance.

piece.transform.Rotate(Vector3(0, 0, rot));

P.S. I have tried a lot of different ways to rotate the object all of them gives the same problem.


  • You've likely set the object as static, so you cannot move it at runtime.
  • I've checked they are not static. They can be moved with Vector3.up etc.

  • function Update()
    transform.RotateAround(transform.position, transform.up, Time.deltaTime * 90f);
  • edited
    @bischonator that does rotate the object but not the way I want it to.

    The 2 versions of the script below works but again it rotates the wrong way, for some reason only rotation around the z axis doesn't want to play along.
    piece.transform.Rotate(Vector3(0, rot, 0));
    piece.transform.Rotate(Vector3(rot, 0, 0));
  • Not sure what to tell you, @RuberDucky. This code is right.
    Have you tried just putting the script on a primitive?
  • Hi, to get a better understanding of the issue, can you share the following:

    Snapshot of the hierarchy for the object - sometimes, having the script on the wrong child can cause funny issues.

    Snapshot of the object properties (the one with the script) - there could be other behaviours that interferes with the rotation. For example, if you have a rigidbody attached that freezes some of the axis the you could experience this behaviour.
  • Ok so the problem was that the rotation angle was such that you don't see a difference when you rotate it. Thanks for the help guys.
  • Ah, depending on what exactly you saw it was probably a Gimbal Lock. Great explanation: https://en.wikipedia.org/wiki/Gimbal_lock
Sign In or Register to comment.