4
\$\begingroup\$

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 ?

\$\endgroup\$
2
\$\begingroup\$

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.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Thank you. How to parent an empty GameObject to the cube? \$\endgroup\$ – eon Sep 12 '18 at 13:20
  • \$\begingroup\$ Just create an empty GameObject then drag the cube from the hierarchy and drop it on the GameObject you just created. \$\endgroup\$ – Saifiction Sep 12 '18 at 16:39
  • \$\begingroup\$ The solution limits the use cases only to those when you are not going to modify the width or height of an object at runtime. \$\endgroup\$ – qqqqqqq Mar 28 at 10:30
2
\$\begingroup\$

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.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

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.

enter image description here

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.

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

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.

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ That is a wrong answer. Please, check the answer I provided. \$\endgroup\$ – qqqqqqq Mar 28 at 10:28
  • \$\begingroup\$ Your code doesn't modify the pivot point of the mesh at all. It offsets the position of the parent object and adjusts the child positions accordingly, so that you can just temporarily rotate an object around the desired point in space. \$\endgroup\$ – With A SpiRIT Mar 29 at 7:16
  • 1
    \$\begingroup\$ I am not sure that we are on the same page. Could you, please, tell me the definition of the pivot point? Because, I can find nothing in the definition of the pivot point which would make my solution the one which doesn't modify the pivot point of the mesh at all. :) \$\endgroup\$ – qqqqqqq Mar 30 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.