8
\$\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\$ Does this technique help you? Unity: Set new Origin using empty GameObject \$\endgroup\$
    – DMGregory
    Sep 12, 2018 at 12:58
  • \$\begingroup\$ Yes, in a way. If I change origin to pivot, does it stay that way indefinetely ? \$\endgroup\$
    – eon
    Sep 12, 2018 at 15:02

5 Answers 5

4
\$\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.

\$\endgroup\$
3
  • \$\begingroup\$ People in this thread mention that having "Pivot" instead of "Center" selected will inherit the pivot point set in the modelling app. \$\endgroup\$
    – A__
    Jun 2, 2021 at 22:38
  • \$\begingroup\$ this is incorrect. you can set a pivot in 3ds max for unity to properly use it as the pivot. it's vastly inefficient to have to create extra gameobjects when you can just have your model have proper pivots. \$\endgroup\$
    – ina
    Jan 18, 2022 at 12:20
  • \$\begingroup\$ Note, if the pivot point on the mesh itself is cenered, then setting this menu option will do nothing. \$\endgroup\$ Oct 27 at 1:49
4
\$\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.

\$\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.

\$\endgroup\$
3
  • \$\begingroup\$ Thank you. How to parent an empty GameObject to the cube? \$\endgroup\$
    – eon
    Sep 12, 2018 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, 2018 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, 2020 at 10:30
2
\$\begingroup\$

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).

https://github.com/yasirkula/UnityAdjustPivot

\$\endgroup\$
2
  • \$\begingroup\$ As it's currently stated, this looks like a link-only answer. Please edit to include additional information about how your solution can be applied to solve OP's issue. \$\endgroup\$
    – liggiorgio
    Jan 18, 2022 at 21:08
  • \$\begingroup\$ it just works. it's not my repo. it's what i use to change the pivot in editor when i have to, esp for free models i find online. \$\endgroup\$
    – ina
    Jan 19, 2022 at 8:16
1
\$\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.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ That is a wrong answer. Please, check the answer I provided. \$\endgroup\$
    – qqqqqqq
    Mar 28, 2020 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\$ Mar 29, 2020 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, 2020 at 20:54
  • \$\begingroup\$ The pivot point or origin in Blender is the central point of the 3D object. When you move or rotate your object, its relative or pivots around the pivot/origin. Indeed, you cannot change the pivot directly in Unity. @qqqqqqq you could change in the Unity Scene view between Pivot and Center to see the difference. \$\endgroup\$
    – Georodin
    Oct 12 at 13:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .