Change pivot point of gameobject
Is there a way to simply change the pivot point of a gameobject and make it rotate around a different axis than the middle axis? thanks!
Answer by Hartnett · Apr 26, 2018 at 03:16 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.
But, does ProBuilder allow us to change the pivot of an existing gameobject? If I have a cube, ProBuilder doesn't allow us to change it's pivot to any corner of the cube.
I just checked to make sure of this, but you can indeed change the pivot point of an existing object using probuilder as of unity version 2018.1.2f1 and probuilder package 3.0.8.
Select the object that you want to set the pivot of
Click "Probuilderize" in the probuilder window
$$anonymous$$ove the point on the object that you want to be the new pivot to world space 0,0,0 (Note: you can also rotate the object at this point if you want to change that as well)
Click Freeze Transform in probuilder
At this point the pivot is set to the new location and rotation based on 0,0,0 world space. If you want you can now go Tools>Probuilder>Actions>"Strip ProBuilder Scripts In Selection" if you want to remove the extra probuilder scripts from your object.
This is the thread I should've responded to, so I'll respond here as well.
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, 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.
Answer by Kurt-Dekker · Oct 26, 2018 at 01:22 AM
@cyllu2 Many of these incorrect answers are how to move mesh geometry relative to the transform position, and do so using the features of ProBuilder.
The actual correct answer to the OP's question is that "No, the Transform in a GameObject cannot do that." The work-around is what was posted by @Mindmapfreak : use another parent GameObject where you want the pivot to be.
Answer by Mindmapfreak · Jun 25, 2016 at 05:30 PM
You can find answers to that here, here and here.
You can embed your model inside an empty GameObject and position it wherever you like - this allows you to create any pivot point if you then use the outer game object.
I am not sure what you mean by "middle axis" ...
hmm, yes I saw those answers, I was wondering if there was a better solution :) I'll take a look at that guy's script, thanks!
This is the "better" solution. It's the simplest too.
The best solution probably is to set the pivot point correctly in your modeling software ;)
NONE of those answers actually answered the question. Am I on StackExchange?!
Answer by zleereed · Aug 01, 2019 at 02:45 AM
in most 3d modeling software you hit 'insert' key to change the pivot point of an object. Unity doesnt do that? Seems fundamental?
Answer by Brain-_-Fail · Dec 12, 2019 at 04:08 AM
Unfortunately in Unity, modifying the actual pivots is not possible out of the box. I know this is really annoying and something that i always wanted in Unity. So i decided to create an editor utility for the same.
You can try out my asset here:
https://assetstore.unity.com/packages/tools/utilities/pivot-modder-152501
It allows you to modify pivot position and rotation conveniently from within the unity editor, it also provides you with various useful options like pivot snapping which allows you to manipulate the pivot more precisely. It also fits right within the inspector and needs no addition of components and opening windows from the editor.
Seems like a well made asset! But I need to change the pivot point during the game through script. Is that possible with Pivot $$anonymous$$odder?
Yeah that's absolutely possible with the runtime APIs and it does it blazingly fast too. Read the API docs here https://brainfail.000webhostapp.com/pivotmodder_runtime_api_docs/html/class_pivot_modder_runtime_1_1_pivot_modder_runtime.html
Your answer
Follow this Question
Related Questions
Unity 3d rotate gameobject in touch direction over an axis 0 Answers
how to have a game object face its target ? 1 Answer
Looking for a simple rectangle mesh with corner pivot 0 Answers
How do I rotate a game object around a custom pivot? 1 Answer
Sprite changes the child local position,Sprite pivot change Vector3.zero postion of child gameObject 1 Answer