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 /
avatar image
0
Question by Unity_scat · May 15, 2017 at 05:16 AM · axisrotation detectionpositions

How to find what positional axis an object's green axis corresponds to?

I'm trying to find out what positional axis an object's green axis corresponds to with varying rotations.

For example, if Object A had a certain rotation, its green axis would correspond to its Z position. And if Object B had a different rotation, its green axis would correspond to its X position. What code will help me determine the green axis's positional axis?

Comment
Add comment · Show 1
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 leech54 · May 15, 2017 at 08:08 PM 0
Share

If I understand your question correctly

red = x axis green = y axis blue = z axis

if you rotate on those in the inspector you will see rotation about these axis.

2 Replies

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

Answer by Kristinosis · May 15, 2017 at 05:24 PM

If I'm understanding your question, you're trying to detect which global axis your object's green axis is pointing to? So if your object had zero rotation and its green axis was pointing straight up, meaning it corresponds to the global y axis, but if it was rotated 90 degrees on the z axis then now the green axis would be pointing right, and corresponding to the world x axis. Is that right?

If that's what you're asking, you could do a simple check by comparing transform.up with Vector3.up, Vector3.right, and Vector3.forward. You could also compare angles if you want to get the closest global axis that the green axis points to. I could probably write out some code when I get home but you should try it out yourself first.

If that wasn't your question, do you think you could maybe reformulate it?

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 Unity_scat · May 17, 2017 at 01:37 AM 0
Share

Thanks! Comparing the object's transform.whatever to Vector3.forward worked!

avatar image Kristinosis · May 17, 2017 at 05:01 AM 0
Share

Glad you could get it working :)

avatar image
0

Answer by Bunny83 · May 15, 2017 at 06:13 AM

Your question is a bit confusing. The green axis inside the scene view when, the scene view is switched to "local", is always transform.up ( which is always the y-axis of that object in worldspace), no matter how the object is rotated.

If the sceneview mode is switched to "global", the green axis is always aligned with the world and therefore completely independent from the object rotation. Though transform.up is not affected by this setting.

In general the x axis is red, y is green and z is blue. To avoid confusion it's recommended to use the mode "local" and "pivot" instead of "global" or "center". If you use one of these you should understand that it's just a visual tool to simplify certain editing actions in the sceneview. Changing this setting in the Unity editor does not affect the object itself.

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

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

6 People are following this question.

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

Related Questions

How do I limit the x axis on a first person controller? 1 Answer

use world axis when using transform.rotate 3 Answers

Spinning a sphere, like a globe. 1 Answer

Can I control an axis with a script or is there an axis substitute? 1 Answer

Rotate and Move towards Mouse Point 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