I am running
private void Update()
transform.Rotate(Vector3.up, 90, Space.Self);
on a game object.
If I put this script on a "simple" mesh object it works as expected (for each Frame, the object is rotated by 90 degrees). However, if I put this script on an "empty game object" (that contains "real" objects as children), the children do not rotate. Why is this?
The children do not have any script/animation/... attached, they are simple mesh objects with a renderer and a collider.
The same approach fails with various other methods to rotate the object as well, including transform.rotation = ..., transform.localRotation = ... and other overloads of the Rotate-Method.
transform.rotation = ...
transform.localRotation = ...
If I create a new Empty GameObject, add the script to it, create another new Empty GameObject as a child and add a mesh to it, the very same thing happens, so re-creation of the tree does not help.
I guess I do overlook something very simple here, but I cannot figure out what it is.
Answer by itr-prototype
Mar 15 at 12:29 PM
Strange thing: as soon as I rename the parent object, it works again.
I hope my Problem is thereby solved, still I'd be interested in an explanation why this can happen at all and if this is correct behaviour.
I rememeber that I previously had another object that had the same name. I deleted this one a few days ago (before I created the one that caused the Problem now), but maybe this is related.
Answer by RecyclingBen
Mar 15 at 11:28 AM
I have used transform.eulerangles w/ children attached and it worked as expected. Maybe try that?
Just tried it, using transform.eulerAngles = new Vector3(0, 90, 0); - same problem. I am quite sure I've tried this before, as well. Anyway, I would find it rather strange if Rotate(...) would not work, but eulerangles = ... would.
transform.eulerAngles = new Vector3(0, 90, 0);
eulerangles = ...
Answer by MeronSoda
Mar 15 at 02:54 PM
Have you tried Quaternion.Euler*?
void Awake ()
tr = transform;
private void Update()
tr.rotation = Quaternion.Euler(0, 90, 0);
I did not create a extra member variable (as transform is already a member), but I did try transform.rotation = ... as stated in the question. Why do you think creating an extra member variable would make a difference? I think this can only make a difference if a new object is assigned to this.transform between the calls to Awake and Update. This does not make any sense from a Software design perspective, at least not if tr.rotation would be more correct than transform.rotation. In the end you'd have 2 members for the same object, introducing a possibility for annoying bugs.
The extra variable was not the focus of the answer, sorry. I was talking specifically about the Queternion.Euler assignment. But, yeah, my bad I didn't notice you had used it already. The cached Transform is just my way to code, always avoiding GetComponent calls, I don't even notice it anymore.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
114 People are following this question.
2D Rigidboy, have child keep upright but allow parent to rotate
Unity 5 - How to addtorque to rigidbody without overriding axis constraints?
Changing parent at runtime rotates object.
How could I make the children of an object face the direction it is moving on the y-axis?
How to Set a Single Axis Rotation of a GameObject?