Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Agustin Petrini · Dec 29, 2010 at 05:06 PM · rotationvector3quaternioninspectoreulerangles

How is the rotation of a Transform converted into a Vector3 in the inspector ?

Every GameObject's Transform has position, rotation and scale values in the inspector. Rotations are represented by a Vector3 (3 values; x, y and z).

How is the Transform Rotation Quaternion converted into this Vector3 ?

I've tried doing Quaternion.LookRotation(aVector3) as well as setting the same values to a Quaternion (and leaving the w on zero) but none the tries gave me the same result as touching the values manually in the inspector.

In other words, lets suppose I have a Vector3 variable in my script and I want that modifing that have the same result as modifing the Transform's rotation.

Example image

Thanks !

Comment
Add comment
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

2 Replies

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

Answer by Sebas · Dec 29, 2010 at 05:37 PM

Are you looking for transform.eulerAngles?

Using eulerAngles will set the exact same values as you can see in the inspector. Unity does the transformation between quaternion and eulerAngles automatically. For more information on this transformation, try Wikipedia or using Google will give you plenty of results.

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 Agustin Petrini · Dec 29, 2010 at 07:32 PM 0
Share

Great, thanks Sebas.

avatar image
2

Answer by Ejlersen · Dec 29, 2010 at 05:39 PM

You are probably looking for:

transform.eulerAngles

or

transform.rotation = Quaternion.Euler(x,y,z);
Comment
Add comment · Show 3 · 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 Agustin Petrini · Dec 29, 2010 at 07:33 PM 0
Share

Thank you Ejlersen, the 2nd one was exactly what I was looking for.

avatar image Murat_141 · Mar 26, 2016 at 10:12 AM 0
Share

Thank you very much.

avatar image Bunny83 · Mar 26, 2016 at 10:23 AM 0
Share

Actually what you see in the Inspector is transform.localEulerAngles. transform.eulerAngles is the worldspace rotation while localEulerAngles is the relative rotation to it's parent object.

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

2 People are following this question.

avatar image avatar image

Related Questions

c# modify only one axis of a quaternion 2 Answers

How do I make create a rotateable object that follows a raycast hit point? 2 Answers

Turret rotation on one axis problems 2 Answers

Is there no way to get reliable angles from a rigidbody? 2 Answers

Writing a custom LookAt() function 2 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