Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by seanlitow · Mar 26, 2014 at 02:23 AM · rotationpositionchangerotate objectcenter

Cannot rotate an object around the center

I got some answers from the forum and tried them all. Still doesn't work. I need to make the blades rotate, however it always rotate around some axis that is far from center which causes the blades far from the center.`Pig.transform.Rotate(Vector3.forward*(Time.deltaTime)*100);` I know this should be simple, but it just doesn't work. Also, I found something interesting. In the inspector, the position doesn't change at all though it should change. See the image.alt text

t.jpg (13.6 kB)
Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image MousePods · Mar 26, 2014 at 02:25 AM 0
Share

Hmmm, Could you package it up in a unity package? I could take a look at it.

avatar image seanlitow · Mar 26, 2014 at 02:28 AM 0
Share

It's a project in the lab, may not be a good idea to release though. Sorry for that...

5 Replies

· Add your reply
  • Sort: 
avatar image
7
Best Answer

Answer by supernat · Mar 26, 2014 at 02:46 AM

Transform.Roate will not change position. It only changes the rotation of the object around its local origin, just to clarify your comment about why the position doesn't change in the inspector.

The key is the object's origin. The local model origin of an object (called the pivot) like this should be the geometric center but probably on the inside (back side) of the cap. There's a button on the top left of the editor (two buttons side by side). They say Pivot/Center and Local/Global. If you select Pivot Local, you should see the arrows of the blades right in the center of the cap somewhere. If the arrows are far outside this, when you rotate the blades, they'll rotate around those arrows (that's the model origin). You should play with these buttons and learn to use them, they will save you a lot of heartache.

There are three ways to fix this. 1) Re-export from the modeling software with the pivot point set to the cap of the blades. 2) Create an empty game object at the cap in the root of the scene hierarchy, drag the blades into that game object, and then rotate that game object instead of the blades. 3) Get a pivot modifier script from the asset store or write your own, and use it to move your pivot in the editor and re-save it.

EDIT: My answer is assuming your pivot is not located properly. If it is, then something else is amiss, maybe the blades are a child of a game object, and you are rotating that game object instead of the blades. Also, you should be able to select the blades, then modify the Rotation values in the Inspector's Transform. Once you get the blades rotating smoothly, you know you've got the correct center. Lastly, in the modeling software, an initial mistake I used to make was selecting all of the vertices/polys and moving them around instead of moving the object itself around. This places the verts off-center (they may all be around +10 for example instead of around 0. In 3DS Max, you can fix this relatively easy with the Hierarchy Modify Pivot panel.

Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image seanlitow · Mar 26, 2014 at 03:07 AM 0
Share

Yeah, you are right! Thank you so much! Though the thing is that I load the obj file runtime, also it seems that in obj file there is no pivot variable. I think I may try to use method 2 and 3 to solve this. Thank you again!

avatar image seanlitow · Mar 26, 2014 at 03:41 AM 0
Share

I'm little confused about 2), what is the meaning of rotate the game object ins$$anonymous$$d of the blades, I created an GameObject Pig and moved it's pivot in the inspector and then use this`Pig=GameObject.Find("Nosecone");` to try to get the GameObject, however Nosecone still use the old pivot though. Could you give me some idea? Thank you so much!

avatar image Genosis · Mar 26, 2014 at 03:54 AM 1
Share

Hmm, let me put this in perspective for you. So essentially let's take this as your object pivot:

 Y
 ^OOO
 |OOO
 |XOO
 .----->X

The "X" here being the "Pivot". Transform.Rotate will rotate around the X. But I am sure you get that by now.

Create an empty game Object, parent the object to the new game object. If you set the localScale of your windmill object to 0,0,0 the pivot(which is at the corner of your windmil) will be at the center of the new gameObject.

And because the corner of your windmil is now at the center of the parent gameobject, when you rotate the parent game object, it will rotate the entire object with the corner of the windmill being the center of the new gameobject.

I hope you understand that, if not try it out in Unity to get a grasp of what I am saying.

What you are meant to do, according to seanlitow's 2) is to positon the windmill such that the center of the windmill, not the pivot but the center you want, is at the center of the parent gameobject.

So taking C to be the center of the parent gameObject, in this X and Y representation it should look like:

 Y
 ^OOO
 |OCO
 |XOO
 .----->X

So in this case, the coordinate of the gameObject would be (0,0,0) but the coordinate of the windmill would be something similar to(-1,-1,0)

Explanation is messy but I hope you got that...

And then when you want to rotate the windmill, you rotate the parent gameObject ins$$anonymous$$d.

avatar image seanlitow · Mar 26, 2014 at 04:00 AM 0
Share

@supernat, thank you for your suggestion, I used the transform.RotateAround in a wrong way and now I use it again and it works. This function can change the pivot. Thank you so much!

avatar image seanlitow · Mar 26, 2014 at 04:02 AM 0
Share

Thank you @Genosis , I got it.

Show more comments
avatar image
1

Answer by pcdrive · Oct 04, 2016 at 07:25 PM

Hi dude,

You must have find the solution, but i run into the same problem and maybe someone else is looking for it too. Actually i made a simple mistake, and took 2 hour to get it since im a beginner.

When you make a prefab listen to the objects position, because the prefab's pivot will not be where the contained objects pivots are, but in 0,0,0. So if you make a prefab you should listen to where are the object are and move them to the 0,0,0, so the prefabs pivot will be at the center of the object.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image giantkilleroverunity3d · Jul 29, 2021 at 04:54 PM 0
Share

This always need to be done. Reset the new parent GO before childing another.

avatar image
0

Answer by giantkilleroverunity3d · Aug 25, 2016 at 02:53 AM

Using the two buttons in the upper left corner of the game editor can alleviate alot ot problems and questions. I just wish I found this two hours ago. I am using Probuilder to create complex models and need to exercise the transformers visually.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by moritzcerst · Jan 26, 2021 at 06:21 PM

If you use ProBuilder, you can automatically adjust the pivot.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by exactspace · Jul 29, 2021 at 04:03 PM

How do you adjust the pivot in Unity?

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image pcdrive · Jul 31, 2021 at 08:30 AM 0
Share

You can't. But there is a particularly easy way for that. Create an empty gameobject, and assign the object as it's child with an offset position to center it. Finally use the empty gameobject instead of the other. It's even easier if you make a prefab out of it

avatar image giantkilleroverunity3d · Jul 31, 2021 at 04:53 PM 0
Share

Ah but one can: https://assetstore.unity.com/packages/tools/utilities/adjust-pivot-112883

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

27 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to calculate the real position after rotate with a original point without using Transform in 2D game 1 Answer

SOLVED Rotate object smoothly to calculated angle on key press (and change the target angle during rotating movement) 1 Answer

Rotate Z-Axis towards center. 0 Answers

Editor like position and rotation change of a game object 0 Answers

Rotate an object back to its old rotation 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges