Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 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 /
  • Help Room /
avatar image
4
Question by SimonClintonIv · May 31, 2016 at 01:48 PM · rotationobjecttrack

How to get rotation of an object using C#

This is the code that I have written to get an object rotation

alt text

The object’s X rotation is 45

alt text

But on the console I am getting 0.3826835

capture.png (12.0 kB)
capture2.png (10.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 SimonClintonIv · May 31, 2016 at 11:28 AM 0
Share

In the code I have written local rotation but I want global rotation

avatar image Hellium · May 31, 2016 at 01:50 PM 0
Share

c.transform.location is a quaternion

In theinspector, the rotation is shown in euler angles

3 Replies

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

Answer by mikelortega · May 31, 2016 at 01:59 PM

c.transform.localRotation.eulerAngles.x

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 SimonClintonIv · May 31, 2016 at 03:15 PM 0
Share

Thanks a lot, your code works.

avatar image shinichikudo997 · Oct 06, 2020 at 06:26 AM 1
Share

This isn't working for me, I am getting a value not even close to the actual in inspector during runtime. Any changes? Please help

avatar image
4

Answer by pjkokane21 · Sep 10, 2021 at 05:01 AM

[PROBLEM SOLVED]

.

Skip all the above coments.

.

I found a way to get the exact rotation values as in INSPECTOR

.

.

I am showing for angle (x)

,The code is as follow

.

  public Transform GameObject;
  
  void Update()
  {
      float Rotation;
      if(GameObject.eulerAngles.x <= 180f)
      {
          Rotation = GameObject.eulerAngles.x;
      }
      else
      {
          Rotation = GameObject.eulerAngles.x - 360f;
      }
  }
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
0

Answer by wes4ray · May 09 at 09:08 PM

Have you tried using Visual Scripting or Bolt? if you are new to coding these could help with learning what things do and not so much did i spell something wrong. you can also watch your script in action as it runs.

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

10 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

Related Questions

Unity Bug? Parent object rotates around child object. 1 Answer

Clicking on an object to make player face it 1 Answer

How i can set Start Position and Ending position in ROTATION AROUND AXIS? 0 Answers

how do i rotate an object? C# 1 Answer

What is the vr head input for google vr sdk v1.130 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