I'm trying to rotate a GameObject that consists of several cubes around its center of gravity on an axis.

When using transform.Rotate(), it rotates around its pivot point (as shown in picture 1) and not its center of gravity as I want (picture 2). How can I achieve this rotation?

Picture 1: Picture 1

Picture 2: Picture 2


Move your sub-components from the centre of mass to the pivot point:

  1. Find the centre of mass of your object.
  2. Compute the vector between your centre of mass and the pivot point of your object.
  3. Use that vector to move your cubes so that the centre of mass of your object is at the same place of the pivot point of your object.
  4. Perform your rotation. (Also rotate your computed delta vector.)
  5. Replace the cubes with the negative delta vector you computed earlier.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.