- Home /
Move gameobject pivot
Hi, I have a gameobject with a very odd pivot point (at least that's what i'm presuming it is), and so when I rotate the object in my script it rotates on that point so I'd like to adjust it's position to a more practical place
I have tried using the SetPivot point script provided on the unity3d community wiki but it only works on meshes (?) and when I try and use it on my hands mesh it always turn out like so;
Any help is much appreciated
Answer by iagoccampos · Jun 12, 2015 at 02:04 AM
You can't change the pivot, but you can create a custom pivot, to do this create an ampty GameObject and attach whatever GameObject you want to this empty GameObject.
i just tried that and it didnt work... I set the empty objects transform where i want it to pivot... then attach the new object to the empty object as a child... but as soon as I do, the empty objects transform now is the center of the new model I just popped in
I had the same problem. Googled a bit more. Found the solution on Stackoverflow
To summarize: Check the pivot setting at the top of your editor. $$anonymous$$ine was set to: "Center" and "Local". You should set it to: "Pivot" and "Local". Check the link for screenshots.
Hope it helps
I know I'm a bit late but I wish I could accept your answer as this is the solution that worked best for me.
Wish I could upvote this more! Thanks guys this fixed it for me! To summarize:
PROBLE$$anonymous$$: Could not move pivot point on gameobject. SOLUTION: Create new empty gameobject > parent desired gameobject to empty
::Notes:: $$anonymous$$ake sure you're in "Pivot" and not "Center" mode -- toggle button located at the top next to local/global Also make sure to change pivot point BEFORE parenting your gameobject, or else you'll need to unparent all your gameobjects again
Answer by Hartnett · Apr 26, 2018 at 03:15 PM
Just wanted to update this with a simple solution that now exists since I was looking for the information as well and I just kept coming across the parent object work around.
Probuilder, which is a unity asset right off the asset store, that I believe they said was going to become standard in the future, has the ability to set the pivot point of an object in editor.
When you have an object selected clicking on "Freeze Transform" will set the pivot point of the object to 0,0,0 in world space while keeping the other transform information of your mesh exactly where it is in world space. So just take the object that you want to correct the pivot of to near 0,0,0, align it how you want and then click Freeze Transform. Very Handy, and officially supported by unity.
There is also a button to set the pivot to the meshes center of mass if you just want to do that quickly.
An added benefit of downloading probuilder is that you can edit meshes in unity as well, which is obviously great.
Probuilder seems like a great tool and I'm glad you've gone around updating all the different threads with this question. Unfortunately for me, however, I haven't been able to get your solution to work for me. I have a 3D object which is a star that I imported from Tinkercad which is enormous and off-center by default, and I have a single script that manages all of the shapes in my game. That's easy when every other shape has an accurate transform, but my star does not because of its transform coordinates that are not actually reflective of the shape.
When I "probuilderize" my star as you mentioned in another thread, then move it to where I want it to be as 0,0,0, then hit "Freeze Transform," the star shrinks! And none of the coordinates are reset to 0. They all stay the same. No errors or issues pop up. I just have no idea why it doesn't work. I can take a video if you'd like.
Awesome, it just happened that I created my object in Probuilder. This comment helped enormously!
Answer by kferkic · Mar 03, 2019 at 08:47 PM
Some export formats (like Collada) include the pivot point of the object.
As a workaround, you could open the model in your preferred 3d program (like Blender), set the pivot point there and export the model to Unity. In Unity, you can set the tool handle position to 'Pivot'
Answer by hally · Nov 18, 2019 at 05:36 PM
I found this video tutorial which helped me to resolve the problem with a pivot - Unity Fix (move and rotate) Origin Pivot Orientation And Position
Answer by Clickpointgames · Dec 31, 2016 at 03:28 PM
Well the custom pivot does work you just need to make sure any scripts that move the player are attached to the empty game object and the original object has not got them scripts and is made into a child of the empty game object.
Your answer
Follow this Question
Related Questions
Weird FPS Camera 0 Answers
Camera to follow a target within a circle? 1 Answer
Gameobject to stay within the view of the camera - c# 3 Answers
Extents of a Compound GameObject (C#) 2 Answers
I want to put main camera floating 0 Answers