Course contentsShow
← Unity Game Development
Lesson 26 of 8281. Unity FoundationsFree lesson

Optimizing Pivot Points for Transform Transformations

Adjust the pivot point of GameObjects to control the center of rotation and scaling operations for more precise animations.

Optimizing Pivot Points for Transform Transformations

In this lesson, you will learn how to shift the "center" of a GameObject to control exactly how it rotates and scales.

Understanding the Pivot

Every GameObject has a Pivot Point, which acts as the anchor for all transformations. When you rotate or scale an object, Unity performs these calculations relative to this point. By default, many 3D models have their pivot at the absolute center of their mesh.

However, imagine a door. If the pivot point is in the middle of the door, it will spin like a propeller. To make it behave like a real door, the pivot needs to be at the edge where the hinges are.

The "Empty Parent" Technique

Since you cannot always modify the internal geometry of a model, the best way to optimize your pivot point in Unity is to use the Empty GameObject pattern. Instead of rotating the model directly, you create a parent container:

  1. Create an empty GameObject (GameObject > Create Empty).
  2. Move this empty object to the position where you want the "hinge" or center of rotation to be.
  3. Drag your visual model into the Hierarchy as a child of that empty object.
  4. Now, when you rotate the parent, the child will rotate around the parent's position, effectively changing your pivot point.

Why This Matters

If you are animating a swinging pendulum, a rotating blade, or a character’s limb, setting the pivot correctly saves you hours of manual coordinate adjustments. By using a parent container, you keep the model's local coordinates clean while gaining precise control over its movement.

// Example: Rotating a door child object via its parent "pivot"
public class DoorHinge : MonoBehaviour 
{
    void Update() 
    {
        // Rotating the parent (the pivot point)
        transform.Rotate(0, 10 * Time.deltaTime, 0);
    }
}

By placing this script on the parent "Empty" object rather than the visual mesh, the door will swing correctly on its hinge rather than spinning wildly around its center.

Key Takeaway: The pivot point dictates the center of rotation and scale; if your object isn’t moving naturally, use an empty parent GameObject to define a custom pivot anchor.