- Home /
How to change the pivot point of a 3d game object in unity
I was tring to make a 3d game in unity and I need to change pivot point of a object
Answer by Buura · Sep 30, 2020 at 09:18 AM
You can create a root gameobject, set that object to main object's parent and arrange you child object. Use the root as your main object afterwards.
I am new to unity ,I have no idea about root gameobject do you have another method to move pivot point ?
Note that the pivot is not a "thing" that can be "set". The pivot of an object is simple the origin of your local space. It's defined by all your vertices. So a vertex that has a local space position of (10, 5, 0) it is located 10 units to the right and 5 units above the origin / pivot. In order to move the pivot you would need to offset all vertices of the mesh by the same amount.
Unity is not a modelling application. If the pivot of an imported model is not rignt, go edit it in the application it was created in. This is the same for pretty much all imported assets (audio, textures, models, ...)
Using an empty gameobject like Buura suggested is an easy workaround. For example to take the example from above, if we want the vertex (10,5,0) be the pivot / origin we can simply make the model a child of an empty gameobject and move the model object inside the empty gameobject to the local position (-10, -5, 0). So relative to the new / outer object the vertex in question is now at (0, 0, 0).
If you have trouble understanding this simple relationship you really need to learn about kinematic chains and coordinate systems / coordinate spaces. Those are fundamental concepts of any 2d or 3d applications. If you have trouble with vectors, vector spaces and / or linear algebra in general I would recommend the essence of linear algebra series.
ps: If you import your mesh with the "readable" flag set you could offset all vertices at runtime from a script. However if the pivot is just at the wrong position it should be fixed at the source.
Right click on an empty place in the hierarchy window. Create an empty gameObject. Set the new gameObjects position to 0,0,0. Select your previous object and drag it on to the new gameObject you just created. voila!
Your answer
Follow this Question
Related Questions
Creating 3d maze game 1 Answer
Whats The difference? 1 Answer
getting udp package info inside unity (GlovePIE) 0 Answers
2D C# destroy a GameObject on collision 2 Answers