Rotation Problem

Hi Everyone,

I have a cube inside a sphere and those inside a plane as shown in the hierarchy view (in the pic below).

I am trying to rotate the sphere that should rotate the cube alone with it.

However it all gets messed up when I apply code.

The simple code I used is:

transform.Rotate(Time.deltaTime* -20, 0, 0);

it causes rotation like this in the pic below.

This is the result I want: Only works properly why sphere is not in plane.

If anything but the lowest child, has a non even scale, so, not 1,1,1 but 3,2,1, the child oft hat object,and any child with in, will be deformed. Make sure all are set to 1,1,1.

That did not fix it though.

And why does it rotate properly while outside of the place?

bump. I really need some help with this.

So, what is your issue? The scale deformation or the rotation? And, does it rotate only if not in contact with the plain? Please explain.
Thanks.

What are the scales and rotations of the three objects?

My issue is not scaling. My issue is the sphere and the cube break away from each other when rotating.

This happens only while inside plane object (in the hierarchy)

The scales are not 1,1,1. Scaling is not my issue though. My issue is the sphere and the cube break away from each other when rotating.

The scales are not 1,1,1 or they are? Cant figure out if that was a typo… if they are not uniform, the odd behaviour you are seeing is probably scale related… looking at the picture, it certainly seems that way.

What about positions, are they all set at zero?

You might need to use RotateAround.

Break away… I am thinking the colliders on these items are not triggers. If so, then of course, they would break away.

lol, dont ruin what was probably right by throwing in something completely wrong :wink:

ummm.
the usual again James, really?
You don’t think that perhaps, he has to colliders, non triggers on each, that is causing the “break away” as he describes it?

Having just recreated the scenario, You’re correct. Its scaling that’s the problem.

As for the last part, here are some things to consider…

  1. Standard planes/spheres/cubes only come with a collider. No rigidbody.

  2. Do you think the colliders would re-act that way if they were parented, or if they were not parented, and what would be the result?

Scaling is not my issue.

I set them changed the scale and still experienced the same problem.

As stated the problem only exist when I make the sphere and cube children of the plane.

Also when I disable the colliders the same problem exist.

It only rotates properly when I don’t make the sphere and the cube children of the plane. That is the only thing that fixes it.
I do need them to be children of the plane though.

It is a world and local issue?

If the plane you are trying to parent them to is not scale 1,1,1 you are going to have this problem.

An easy solution if you need to just have the appearance of it being a child, is create an empty gameobject, make it the parent of your plane, and the parent of your sphere setup.

Treat the gameobject as the object you want to control. This way your planes and spheres can have whatever scale you want, as long as the root stays at 1,1,1

Why do they need to be children of the plane? Why not have them all under an empty game object?

I will be honest tho, this is a peculiar problem. Can you make a video?

Ok i will try your suggestion and get back to you. In the morning though when I get home

Will make a video if this doesn’t fix it.

If you end up filming it, make sure to use a few tabs of the project scene with different angles, so we can see it from different perspectives.
Thanks, hopefully it doesn’t get to that tho and you solve it!!!

So it turns out the scale of the plane was causing the problem.

Why does this happen? I just want to understand.

if you have an object with a child, both at scale 1,1,1
then no worries, everything remains in proportion.

if you have the parent then become scale 1,2,1
then the child, while locally, still has scale 1,1,1,
in itself is effected by its parnets scale, and appearss as scale 1,2,1

just as if you have a child and parent at position 0,0,0
if you move the parent to 30,0,0, the child while locally is still at 0,0,0,
appears to be at 30,0,0.

When you make your sphere a child of the parent, you will notice that the scale of the sphere changes to make it appear as 1,1,1.

In my test, the new scale became something like 1, 0.5, 0.33 (when the parent had a scale of 1,2,3).

If you can avoid changing the scale, definitely do, as it also scales the physics calculations, which can lead to some interesting (undesirable) results.