Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Change an object's pivot point?

Discussion in 'Editor & General Support' started by mrittman, May 12, 2009.

Thread Status:
Not open for further replies.
  1. mrittman

    mrittman

    Joined:
    May 11, 2009
    Posts:
    40
    Hey I can't find this anywhere...Can someone tell me how I might go about changing an objects center point? I imported an object from 3ds max into Unity but Unity reset its center point to the center of the object.

    Thanks!
     
    blox5000 likes this.
  2. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    Tacitly, Majk3l, avat_ov and 7 others like this.
  3. mrittman

    mrittman

    Joined:
    May 11, 2009
    Posts:
    40
    I tried messing with both those buttons and they didn't do anything...
     
    Soogbad and blox5000 like this.
  4. mrittman

    mrittman

    Joined:
    May 11, 2009
    Posts:
    40
    Figured it out. You have to convert the object to an editable poly inside of 3ds max before exporting it.
     
    Missempoi and blox5000 like this.
  5. remotedeveloper

    remotedeveloper

    Joined:
    Aug 5, 2008
    Posts:
    9
    I too would like the answer to this, I have created a simple object in my 3d app (Modo) and although the pivot points were set correctly in the app they appear to be quite a way off on the x axis in Unity.

    If I change the pivot point in Unity it does indeed set the pivot point correctly in the view but when I rotate my object using code it is rotating around the offset pivot and not the correct center point.

    Any help offered is greatly appreciated.
     
  6. swtoasty

    swtoasty

    Joined:
    Dec 10, 2008
    Posts:
    25
    Using silo at the moment and I am having a similar problem. I've tried exporting as .3ds and .objs, and whenever I import them into Unity the pivot point on the objects are always way off center.

    Also, pretty sure that the objects pivot point in the 3d Application is centered...But when imported into Unity it becomes messed up.

    Is there anyway to fix this besides using the empty game object trick?
     
  7. Joe-Robins

    Joe-Robins

    Unity Technologies

    Joined:
    Apr 21, 2008
    Posts:
    430
    Just for future reference RE 3d Studio Max and pivot points, you can modify an object's pivot point inside max at any time using the hierarchy tab see attached image:
     

    Attached Files:

  8. Screenhog

    Screenhog

    Joined:
    Jul 2, 2009
    Posts:
    498
    Sometimes, the easiest solution is just to parent your mesh to an empty GameObject that was placed where you want your pivot point to be, and rotate that instead.
     
  9. NoirTalon

    NoirTalon

    Joined:
    Sep 20, 2009
    Posts:
    1
    There are just going to be times we have a bogus pivot point in a model, and we want it to rotate in a sane manner. It may very well be a bug that unity does not rotate about an objects center, or the bug may be that the pivot point can not be changed once the model is imported. I won't debate that here, but I will provide a fix.

    1)Create a new blank object in your scene, give it a name like "WackoPivotPoint"
    2)Put that object just where you want the pivot point to be, for the errent model
    3) Now make this new blank object a Child of the errent model
    4) whenever you want to rotate the errent model in script, use the "find" function from the errent model's transform. find the child transform by name. In this case
    Code (csharp):
    1. pivot = errentModel.transform.Find("WackoPivotPoint");
    5) Next use the RotateAround function to, well, do just that. in this case
    Code (csharp):
    1. errentModel.transform.RotateAround(pivot.position, Vector3.up,20)
    the following code uses a child transform called "SelectorPivot" to rotate around by 20 degrees


    Code (csharp):
    1.     var pivot : Transform = transform.Find("SelectorPivot");
    2.     this.transform.RotateAround(pivot.position, Vector3.up, -20);

    I hope this helps!

    P.S. don't bug me about the spelling. It's 2:45 am, and I just don't care.
     
    MRC-UA, Fabi0011, am_GA and 4 others like this.
  10. Westland

    Westland

    Joined:
    Jan 26, 2015
    Posts:
    27
    Ran into this issue, too. I was making several parts of an object in my 3D program, exporting them individually - ran into this issue with one of the exports. I messed a little with it, and it turned out, if the exported object in the 3D program was offset from the 0,0,0 point of the scene, that offset would come out with the export (and into Unity). So putting the object in the centrepoint of the scene before exporting, fixed it entirely.

    Rather odd, since there's plenty of other objects in the scene which were exported with an offset, and came in with a perfectly-centered pivot point in Unity anyway... No clue.
     
    amazingjaba likes this.
  11. Santiago1985

    Santiago1985

    Joined:
    Sep 19, 2013
    Posts:
    1
    -Create another empty object.
    -Put the object you want to rotate as a child of the new empty object
    -Move the object you want to rotate placing the desired pivot point in the center of the new (not emtpy anymore) object
    -From now on rotate the new object instead of it's child.

    That worked for me
     
  12. JohnnyBeCool_

    JohnnyBeCool_

    Joined:
    Aug 24, 2016
    Posts:
    1
    Hello everyone!, I've been strugglin the whole morning with the same issue presented above, NoirTalon made a great aportation and I'm willing to do too, here I found a tutorial solving the problem step-by-step, though i post this years later I hope this will be as useful as it was to me.

    http://www.41post.com/4101/programming/unity-rotation-controller

    Regards.


     
  13. EdGann

    EdGann

    Joined:
    Jul 17, 2016
    Posts:
    8
    You just saved me a lot of time.
     
    amazingjaba likes this.
  14. Westland

    Westland

    Joined:
    Jan 26, 2015
    Posts:
    27
    True, but just in case anyone's forgotten and/or don't know, this can add additional issues to working with the object in the future. Things like the object scale being linked to the parent scale (the 'ratio'), or if you're traversing the hierarchy searching for components via scripts (stuff like transform.parent.GetComponent) and so forth.

    Always best to catch things like this before it goes too far, and work from best practice, which in this case would probably be not having the pivot point issue at all, through a "correctly" done and exported model.
     
    jgwinner likes this.
  15. BigScary

    BigScary

    Joined:
    Jun 4, 2014
    Posts:
    7
    Guys I'm having an awful time with this. I bought some assets with this pivot point problem - both in the meshes and the provided prefabs. When I tried importing the .obj files into blender and then re-exporting them each one at a time repositioned at the origin of my edit space, that fixed the pivot but the round-trip into blender made the assets look less awesome.

    So then I found a nifty editor plugin that sets a game object's pivot point. I thought my problems were solved - I spent 2.5 hours creating 20 new prefabs to replace those in the asset pack. Then I discovered that when I quit unity and open the project again later, those pivot adjustments were lost - they were only in memory and not saved in the in-scene objects or prefabs.

    I know I can make this work by building new prefabs where my models and their collision meshes are offset the same, but parented under a new object so that they can be locally offset. But that presents two annoying issues - I have to refactor my scripts to use this new organization for my objects, and I have to re-export my collision meshes so that they have the same bad offset as the render meshes they're supposed to match up with.

    Are there any better solutions? Ideally,a way to permanently adjust a game object / prefab's pivot point in the editor which actually saves across unity editor sessions??
     
  16. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,042
    No.
    Technically, the pivot point isn't a thing. It is always 0,0,0. Children are offset from that. Meshes are a collection of points (verts and other things like bones) that are positioned relative to the zero point.

    As said above you can nest it in a parent and move it inside that. For meshes, you need to go into a 3D app and adjust it there. (There is no reason it should look any different from the original, unless you changed something else or exported incorrectly).

    You could write an editor script that reads the Mesh and offsets the verts. Then save it as a new mesh object. But that could be problematic for animations, rigs and skinned meshes. And you would have to save it to a seperate object, you cant modify the source file from within unity. That just leads to other problems if you want to change the model in the future. There really isn't a need to do this, especially for changing an offset.

    So there are two options, parent it, or change the source. Everything else is just adding uneeded problems.
     
    jethrogillgren and Westland like this.
  17. Kalladystine

    Kalladystine

    Joined:
    Jan 12, 2015
    Posts:
    227
    For other users sake, it might be good to contact the creator of the asset. It can probably be solved pretty quickly by the person who originally made it and you won't have the issue anymore.

    And if that person is not interested in fixing it, leaving a review at the asset store for it warning about the issue might be warranted - worst case it will benefit potential buyers that don't have the knowledge on how to fix it, best case the creator will be then motivated enough to do something about it.
     
  18. Amoldadu

    Amoldadu

    Joined:
    Feb 3, 2017
    Posts:
    1
    OracleOfNothing likes this.
  19. anuraj250

    anuraj250

    Joined:
    Feb 17, 2018
    Posts:
    1
    1. create an empty game object.
    2. move/set it to location where you want the pivot to be.
    3. Add the model/object to that empty object.
    you can now rotate the model/object from the desired pivot point by rotating the parent object.
     
  20. Hartnett

    Hartnett

    Joined:
    Sep 10, 2015
    Posts:
    2
    Just wanted to add that the Probuilder Asset has the ability to set pivot points, and its pretty handy. Its called "Freeze Transform" and it just sets the pivot point to world 0,0,0 while keeping the mesh where it is in world space.

    There is also a button to set it to the center of mass.

    Since Probuilder is a Unity owned and controller asset this seems pretty solid.
     
    sadicus and AppCity like this.
  21. WhosTheBoss

    WhosTheBoss

    Joined:
    Jan 8, 2013
    Posts:
    64
    It's also very important to note that the Unity editor should be set to Pivot/Local. If not, Whenever an object is added as a child, Unity will automatically calculate a new pivot point that is halfway between the Parent and Child objects.

    To set the Unity Editor to Pivot/Local, There are two buttons on the Top left corner of the editor, next to the 'Hand Tool, 'Move Tool', 'Rotate Tool', 'Scale Tool', 'Rect Tool', 'Move, Rotate, Scale Too' buttons.
     
  22. Jonue

    Jonue

    Joined:
    Dec 16, 2017
    Posts:
    1
    You, sir, are a genius!

    That's exactly what I did now. I created a lot of empty 3D objects with the specific position of the preferred pivot. If you rotate those as desired and keep the actual 3D objects inside without transform, they'll align properly. Afterwards, if you want to remove the empty 3D objects, you can just delete those and can keep the actual 3D objects with correct values.

    Great solution (especially, if you do not wish to alter any pivots)!
     
  23. kpman2300

    kpman2300

    Joined:
    Oct 5, 2020
    Posts:
    32
    I am making a 2D game and when I turn my player to any side it changes its position. My player is made of different parts and maybe because of that only the pivot point is messed up. I don't know what to do plz help!
     
  24. AppCity

    AppCity

    Joined:
    Feb 13, 2016
    Posts:
    8
    Thank you... super helpful. In case it helps anyone else, using the "Freeze Transform" I was able to mirror an object over a global axis.
     
    sadicus likes this.
  25. sadicus

    sadicus

    Joined:
    Jan 28, 2012
    Posts:
    272
    Have not used Unity in a few years, good to know "Ye Olde Parent to Empty" still works. yea add probuilder also helps.
     
    atahfarid likes this.
  26. sadicus

    sadicus

    Joined:
    Jan 28, 2012
    Posts:
    272
    HOW to set the pivot transform in ProBuilder?
     

    Attached Files:

  27. Inventory_Status

    Inventory_Status

    Joined:
    Dec 31, 2020
    Posts:
    42
    In my case, my Pivot is greyed out when I'm trying to edit in prefab mode. I set my Sprit Sort Point to Pivot, but the Pivot Circle is still greyed out. Can anyone help me here?
     
  28. Inventory_Status

    Inventory_Status

    Joined:
    Dec 31, 2020
    Posts:
    42
    Never mind I figured it out. We have to go to our original image (not our prefab) and edit the pivot settings there first (change pivot to custom). Then use Sprite Editor to set the pivot circle where you want it to be. After all this, NOW we go to our prefab of the same image, sprite, etc. and set the Sprite Sort Point = Pivot in the prefab's Sprite Renderer.

    Thanks anyway!
     
    Westland likes this.
  29. autobr

    autobr

    Joined:
    Feb 7, 2022
    Posts:
    3
    In my case I had an object that needed a collider in a certain spot, so I made an empty game object as the parent and positioned the child object in relation to where the empty put the collider.
     
  30. Westland

    Westland

    Joined:
    Jan 26, 2015
    Posts:
    27
    For anyone using Autodesk Maya like me, you hit [Insert] and you're editing the pivot point. Move it as you like, and hit [Insert] to return to.. Whatever the normal edit mode is
     
  31. LDMONTY007

    LDMONTY007

    Joined:
    Sep 7, 2019
    Posts:
    6
    I would like to say for those who need to use the pivot as the center in code, unity uses the "pivot" when positioning relative to the origin of an object. I was looking for a way to make the pivot point the center of mass for an object. If you have probuilder installed you can go into the probuilder window and click "Center Pivot". Hopefully, this helps someone else.
     
Thread Status:
Not open for further replies.