Solving the Pivot problem in Unity

Ever since I started using Unity, I’ve noticed people are frustrated that they can’t move around the pivot of their game objects from within the Unity Editor. Users have to use a 3d modeling application to change the pivot of their models and re-import them into Unity. Unity makes re-importing relatively pain-free but with a game engine so intuitive and easy-to-use, I sort of expected Unity Technologies to solve this problem a while ago.

Being able to extend the functionality of the Editor through Editor Scripts is one of the features I love the most about Unity. And now there is one more reason to adore it; it enabled me to fix this Pivot problem.

SetPivot.cs – view download

If you want to give it a try, you’ll need to create an Editor folder under Assets (Project View) and place the script there. Once Unity is done compiling (should only take 2-3 seconds), you will see the Set Pivot menu item under the GameObject menu. If you have Unity 2.5+, you might want to dock the SetPivot window somewhere to keep it visible while playing with several objects.

There are a couple limitations with this initial version. As of now:

  • You can only move the pivot inside the bounds (aka bounding box) of the mesh. It should take little modification to change this though.
  • Pivot movement doesn’t work well with objects that have been rotated. Remember to move the pivot when the object has zero rotation on all three axes.

I intend to keep improving this script so if you have suggestions, send me a PM on the Unity forums. My forum name is VoxelBoy.

Unity Forum post – view

Unify Community Wiki page – view

Advertisements

About this entry