I have a cube created in Unity scaled 5 times. The pivot of the cube is by default in center.
I would like to change the pivot to the one of the vertices.
How to do that ?
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.
Sign up to join this communityI have a cube created in Unity scaled 5 times. The pivot of the cube is by default in center.
I would like to change the pivot to the one of the vertices.
How to do that ?
unity does not import object pivot from 3ds-max or... but unity uses its own generated pivot point. if you want to switch position between global and pivot you can choose using options upper left of app screen.
simplest way to make a pivot for your object is to make an empty object and make you model object child of that object just by dragging it and drop it on that empty object. and move you child model object to be in right position. after that you can use transform of parent object so child object rotates on parent object position as pivot.
The pivot can be changed in Unity. The following code demonstrates how.
public void PivotTo(Vector3 position)
{
Vector3 offset = transform.position - position;
foreach (Transform child in transform)
child.transform.position += offset;
transform.position = position;
}
I come across the code here when trying to rotate my game object around its center.
You can parent an empty GameObject to the cube you created and position it however you like, this will allow you to control any pivot you like if you use the parent game object.
I use this free asset to have the pivot be changed on a mesh, while in Unity (without needing to go back to 3ds max to fix it).
Unfortunately in Unity modifying the actual pivots is not possible out of the box 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.
doesn't modify the pivot point of the mesh at all
. :)
\$\endgroup\$