- Home /
Question has been asked and answerd by a the user duck in 2010.
Why do grouped Terrain objects move together but don't rotate as one?
I have an empty game object with multiple children added to the base object as a root parent. I can move the parent around and every child follows it but if I try to rotate the parent all the children rotate in different ways.
How can I make all the objects rotate around the empty root parent game object as if they where all one object with one central pivot point?
Is there some setting I need to flip? Everything I am searching and reading says the children should rotate with the parent by default but this does not seem to be correct in my case?
Any help would be greatly appreciated.
Edit: I updated the title of this post as i just tested with simple cubes and a blank game object. It seems things work fine and as expected with cubes but I am trying to make multiple terrains stay together when moved. Is this possible?
When you say rotate in different ways what do you mean? The child objects will keep their position and rotation unchanged relative to the root parent. They will rotate with respect to the world position. Is it not what happens?
I hope I am understanding properly and explaining this right, I have a bunch of objects in a group. They line up edge to edge and when the parent object is rotated each child object moves around it but its not moving as one object. Its breaking into many objects with each child still facing the same direction it started in but moving in a circle around the root. I feel like that's a bad explanation but I hope it makes sense.
So you mean it's like the position of the children are moving along the rotation, but the children are still oriented in their original orientation? As an example, if your object was a human figure and the children objects were feet, the feet are in the right place but are still oriented so the bottom of each foot is still pointed down, no matter how the whole parent object rotates?
Edit: Someone else was quicker. Ignore.
Hi. Please provide more specific information when asking for help.
What Unity version? Can you recreate this behaviour in a new project? Provide screenshots, or even gifs and screen recordings.
How are you applying the rotation? With the editor gizmos, inspector values, scripts,etc.? Beginners often encounter unexpected rotation issues because they do things without knowing how rotation works. What kind of objects are you rotating?
In Unity there is no group feature for objects, only a scene hierarchy. If you create a new empty gameobject, create 5 cubes randomly, making them children of the empty object, and rotate it, thy will properly rotate along the pivot point of the parent.
If you do something custom, with UI elements or 3rd party 2D systems, they might need different handling than just parenting and rotating a transform.
Answer by GrayLightGames · Oct 14, 2019 at 08:50 PM
Hey @Giantbean... I just made an empty GameObject with 2 child SpriteRenderer objects and tried to replicate your issue. All three objects have a RectTransform component and both the anchor and pivot are centered on everything involved. If I rotate the parent empty object, they rotate exactly like you'd like, as one object with a central pivot point. I'd recommend you make a test object like this from scratch in your scene and see if it has the same problem. Otherwise, if you could describe the objects with a little more context, or post a screenshot with what is happening, someone may be able to solve what's going on in your case. Sounds frustrating, hang in there!
Thanks @GrayLightGames. I ran a test with simple cubes as well and it works. It seems the issue is the fact that i am working with terrains. Not sure how Unity handles them as opposed to basic geometry?
Ah that must be it... I haven't used terrains myself, but one of the answers in This Question explains that "No, you can't rotate the terrain. It's not possible to tilt it, or to rotate it around the Y axis.
This is largely due to the many optimisations built-into the terrain engine code, which rely on it maintaining a fixed orientation." There is some mention of editor scripts that will let you rotate at a fixed amount, but if you're looking for a smooth arbitrary rotation, sounds difficult to achieve. Check the link though, you might find something there.