Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by evrov · Nov 10, 2016 at 01:52 PM · rotationaxisrotate objectrotatearound

How to find current vertical axis

Hello, is there a way to find the current vertical axis of an object? alt text

You can see the picture above. After rotation the Y axis is more like X and X is more like Y. But I still need a vertical rotation and in this case around X, but after many different rotation the axis change a lot and do not know which one is vertical - Y, X or Z. Can I always rotate around the current vertical axis?

unitycube2.png (57.2 kB)
Comment
Add comment · Show 4
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 flashframe · Nov 10, 2016 at 02:01 PM 0
Share

Do you mean in the scene view or in code?

In the scene view you can toggle between "local" and "global" handles

local/global toggle

local-global.png (9.3 kB)
avatar image evrov flashframe · Nov 10, 2016 at 02:19 PM 0
Share

I mean in code. I wan to write a script to rotate the cube by its current vertical axis that can be different from Y by rotations.

avatar image evrov · Nov 10, 2016 at 02:14 PM 0
Share

I mean in code. I wan to write a script to rotate the cube by its current vertical axis that can be different from Y by rotations.

avatar image Desoxi · Nov 10, 2016 at 02:52 PM 0
Share

If you just want the local vertical axis you can retrieve it with the following line:

Vector3 verticalAxis = transform.up;

This will give you the local up axis, which i guess, is what you want.

EDIT:

In case you want to rotate around the world y axis all the time you would have to do something like this: transform.RotateAround(Vector3.zero, Vector3.up, 20 * Time.deltaTime);

This should rotate around the world y axis which is unaffected by the local y axis of the gameobject. Dont forget to add the position of the box as first parameter. Here it is set to Vector3.zero which would set the position of your box to 0,0,0 as well. You can find this method here: https://docs.unity3d.com/ScriptReference/Transform.RotateAround.html

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by evrov · Nov 11, 2016 at 01:04 PM

transform.up does not work correct in my case. By different rotations of the cube it loses the original place of the axis. For example the green axis (Y) may be changed to the place where was initially the X axis, as the picture above shows. In one moment I do not know where everyone axis is placed, but i want to rotate the cube from left to right as direction or the rotation must be Vector3.up, but in such a case it rotates again around the original Y axis and the cube rotates different. Is there a way to understand in every moment what is the orientation of every axis alt text

On the picture the X axis now points up and then rotating to right or left must be around X axis.


unitycube2.png (61.7 kB)
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 Desoxi · Nov 11, 2016 at 02:53 PM 0
Share

Hey evrov, i updated my answer above with a codesnippet which lets you rotate aroudn the wodl y axis.

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

93 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 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 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 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

Axis are not rotated as I would expect. 0 Answers

How I can i rotate a bullet after spawning relative to the mouseposition? 0 Answers

How to rotate an object around a player when pushing a button..? 0 Answers

Make GameObject rotate around another around random axis but with fixed distance 0 Answers

constant rotation using keypress 0 Answers


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