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 Zivisx · Jan 08, 2016 at 10:05 AM · c#rotationeulerlook

Rotation changes in an unexpected way Help NEEDED

I have been trying to write a simple code to change the rotation of an object so It looks at my mouse pointer. I would have to say I have seen plenty of people write this and make great examples that work but for the life of my I cant get it to work myself.

After doing some trouble shooting I found that the final line of code was the issue. I can write this line numerous ways but it always gets me the same result. So i changed the code to a static variable (0,0,0) which is what the current rotation of the object is set as so it shouldn't do anything however..... the final line to changes the rotation to (270.7067,0,0) when the code should do nothing but keep the rotation the exact same spot as the current location.

objectX is a quad and a child of another object. The rotation is set to 0,0,0 at the start. The parent objects rotation is (90,0,0) not that I think that matters but what do I know I cant set an objects Rotation.

objectX.transform.rotation = new Vector3 (0,0,0); // This makes it (270.7067,0,0) objectX.transform.rotation = quaternion.euler (0,0,0); // This makes it (270.7067,0,0) objextX.transform.eularAngles = (0,0,0); // this makes it (270.7067,0,0) objectX.transform.rotation = new Vector3 (objectX.x, objectX.y, objectX.z); // This makes it (270.7067,0,0)

Maybe somebody can explain what I am doing wrong

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Zivisx · Jan 12, 2016 at 07:40 PM

I figured it out I believe. Like my previous post said it was a child of an object so the natural rotation of my object when it had no parent was 90,0,0 so I simply made an offset variable in my code and used that to offset the Y making it return to its "default position" . I hope that helps somebody else that has an odd-job rotation problem.

objectX.transform.rotation = quaternion.euler (90,lookAngle,0);

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

58 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

Related Questions

How to set a max rotation angle 1 Answer

Rotation smoothing 0 Answers

Child Object Rotation interpolation problem, 0 Answers

How can I set rotation properly? 0 Answers

Rotated object raycasting in wrong directions!!? 3 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