[Not Solved] Making Child spheres rotate along with the Parent

I am trying to make a sphere spin on its axis (like a planet does). Atm, I’m not worried about making the axis offset like in reality. The prefab is 3 spheres. 1 is parent, and is the “planet”, and the other 2 are children of that 1 sphere and are “clouds”, which are nothing more that slightly larger spheres with a cloud texture and transparency set up on them. It looks good, and the script makes the planet spin just fine. However, the clouds don’t spin at all. And I’ve been searching for hours on how to get the children to have their own spin rates independent of the planet, or even to “inherit” the planets spin. But so far the planet just spins under a stationary cloud-cover. Any help would be great. Also, you can feel free to ignore/delete my code from line 6 to 16 rather than trying to fix it - if needs be. I would be fine with deleting it and putting in all new code since it doesn’t work anyway, and I’m not even sure if I’m on the right track with it.

Oddly, when i run the game and click on the (clone) planet and look at its children… based on the numbers changing in the transform section - they are actually rotating - its just the texture that is on them seems to be stuck and is not rotating with them.

Also, if you couldn’t tell, I’m quite new at this.

public void Setup()
    {
        rb = pInstance.GetComponent<Rigidbody>();
        rb.angularVelocity = Vector3.up * (rotateSpeed / -20);

        if (transform.childCount > 0)
        {
            foreach (Transform child in transform)
            {
                Rigidbody tempRB = child.GetComponent<Rigidbody>();
                if (tempRB != null)
                {
                    tempRB.angularVelocity = Vector3.up * (rotateSpeed / -20);
                }
            }
        }
    }

Kind of a weird bug. Try playing around with the material type to see if it has something to do with that. Change it to be a a standard material (even though it doesn’t have transparency), just to see if the issue still exists.

This is unlikely but could be the planet spinning clockwise with the clouds spinning counterclockwise, giving the illusion that the clouds aren’t moving. would be really funny if this was the case though.

there are 2 other issues.

issue 1, i don’t know if this actually works(EDIT: seems it should work, although I’m not keen on using foreach either way)

foreach(Transform child in transform)

I’d have done this instead to more precisely get the child transform

for(int i = 0; i < transform.childCount; i++){
    Transform temp = transform.GetChild(i);
    //do stuff to child transform
}

issue 2, having child objects with rigidbodies while the parent also has a rigidbody can lead to wonky behaviours. you might want to consider removing the children’s rigidbody components and rotate their transforms directly instead.

Are you using a reflective shader that is just showing an obviously static skybox full of clouds?

I have tried many things, including deleting and recreating. No Dice. =(

They are not, although that would be cool. They are currently a texture (RBG + alpha) applied to albedo on an otherwise blank material. Shader = standard, rendering mode = fade. the mat is then applied to a sphere. that sphere is then made a child of another sphere. Both parent and child have their own Rigidbody. It’s actually quite simple structurally speaking. My skybox is actually a star field, so…no.

Oddly enough, I was thinking this same thing. when I look in the editor during runtime, if i click on the planet, i can see its X rotation changing over time, and if i open it up (its the parent) and click on the cloud sphere/child, it is also rotating, at roughly the same rate over time, but in the opposite direction. So i honestly think it is this. But nowhere in the code have i told it to do this that i can tell. All the code i have for this is posted here, so unless you can see where this is occurring in my posted code, I really have nothing else that i could change that i know of. All of the rotation code is here for you to see. I think there’s some black magic involved. I also adjusted the foreach to a for as you suggested, but it didn’t fix it, and actually, it made no difference whatsoever =( Finally, how would you go about making them rotate without a rigidbody? I need to be able to set their rotation/rotation speed at setup and then let them go on their own. I really don’t want to have to manually rotate them a tiny amount each frameUpdate. Got any suggestions?

More Info/update: I deleted (actually commented out, but hey) lines 6-16 leaving only the 1st two statements in the code and it does the exact same thing. So obviously my code is not doing jack. However, I also tried this, and the results might prove helpful:

        rb = pInstance.GetComponent<Rigidbody>();
        Debug.Log(rb.name + ": " + rotateSpeed / -rotateDamping);
        rb.angularVelocity = Vector3.up * (rotateSpeed / -rotateDamping);
        Debug.Log(rb.name + ": " + rb.angularVelocity.magnitude);

Oddly enough, the planet comes back with the correct amount (-0.5 in the 1st log call and +0.5 in the 2nd) but the clouds come back as -1.0. Note that “rotateSpeed” and “rotateDamping” are both floats.

Any additional help/suggestions are greatly appreciated - as were those already posted. Thanks for the input and I can’t wait to report what was causing this once we get it solved.

If that is the case, I am fairly certain is has to do with child objects containing Rigidbodies. You will have to find an alternative to rotating your planet pieces. You can either do it through script which I believe you know how, or use animation.

What do you have against writing your own script about it though? It’s not like physics or animation don’t update every frame either way, writing your own script which runs on update would make no difference.

but if changing to using a script to handle rotation still doesnt work, it might be the local rotation of the child objects of your planet that is the issue. like it’s been flipped 180 degrees.