[Answered] Parent + Children not rotating correctly

I’m currently using this function to try and rotate the parent:

transform.Rotate(Vector3.forward, Time.deltaTime * 180, Space.World);

but it’s not rotating it like I want it to. It is rotating all the children in the parent the same exact way as parent.
Here’s a 15 second youtube video showing what I mean.

How can I get the object to rotate like in the first part of the video?

I’ve also tried transform.localEulerAngles = new Vector3(0,0,f);
where f is incremented after every update, the results are the same.

Something mighty strange is going on there. You didn’t specify which transform “transform” in your code is referring to, but I think this must be in a script you have running on all the children.

If you actually rotated the parent, instead of each of the children, it would behave exactly like the first part of the video. I’ve done it many times; Unity would be seriously broken (and well near unusable) if it didn’t work that way.

So, please check where your script is, and make sure ‘transform’ refers to the parent, not the children.

I’m running this script on the main camera. I attach the Circle gameobject (the parent object) to the script that is on the main camera, and only tell it to rotate.

This is all the code:

public GameObject circle;

void Update(){
circle.transform.Rotate(Vector3.forward, Time.deltaTime * 180, Space.World);
}

Well I’m stumped. If you post your project somewhere, I’ll download it and have a look. I’m sure with a bit of poking, the problem will reveal itself!

I uploaded it to my google drive, and I attached it as a file on here, so use either to download it.
https://drive.google.com/file/d/0B8X3Qklo1FYoaVphSG9ycXo5dW8/view?usp=sharing

Let me know if you get it to work. Thanks

1817121–116265–UnityRotation.zip (167 KB)

Anybody?

Center the parent to the children:

And remove the scripts from the child objects.
You just want the part object to have the rotate script.

1 Like

That works! Thanks!