• 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 BrodyB · Nov 17, 2011 at 09:12 PM · stucklock

Rotation Locks at 90 or 270 degrees

Hey everyone,

I'm coding a space s$$anonymous$$p object the player can rotate, and due to some weird behavior from the rigidbody's torquing, I'm rewriting it with localEulerAngles. So far it all works perfectly, except the X axis pitch.

What is happening is once my s$$anonymous$$p gets near 90 or 270 on the X axis, the X axis locks into place at 90 or 270 and I'm only able to rotate around the Z axis. I've made sure that not$$anonymous$$ng else I've written is interfering with t$$anonymous$$s code by putting it into another script object, but it still does t$$anonymous$$s. Is t$$anonymous$$s just a quirk of Unity? Is there a way to address t$$anonymous$$s?

 public var rotationThrust : float = 0.3;  // The thrusting power for rotation
 
 private var rot_Pitch : float;
 private var rot_Yaw : float;
 private var rot_Roll : float;
 
 function Update () {
 
     // ROTATIONAL THRUSTERS
     var p = Input.GetAxisRaw("Pitch");
     var y = Input.GetAxisRaw("Yaw");
     var r = Input.GetAxisRaw("Roll");
     
     if (p)
         rot_Pitch += rotationThrust * p;
         
     if (y)
         rot_Yaw += rotationThrust * y;
         
     if (r)
         rot_Roll += -rotationThrust * r;
     
     // ROTATE SHIP
     transform.localEulerAngles.x += rot_Pitch * Time.fixedDeltaTime;
     transform.localEulerAngles.y += rot_Yaw * Time.fixedDeltaTime;
     transform.localEulerAngles.z += rot_Roll * Time.fixedDeltaTime;
 
 }
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
Best Answer

Answer by Eric5h5 · Nov 17, 2011 at 10:04 PM

As the docs say, "Only use t$$anonymous$$s variable to read and set the angles to absolute values. Don't increment them, as it will fail when the angle exceeds 360 degrees. Use Transform.Rotate instead." (Also, localEulerAngles is for objects that have parents; presumably you meant eulerAngles, although as mentioned I'd recommend not using that either.)

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 BrodyB · Nov 17, 2011 at 10:09 PM 0
Share

Thanks, that fixed the problem.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Camera Lock. 1 Answer

Quiz Game Random Question Stuck 1 Answer

My Android Game is not working (unity 19.2) 0 Answers

Starter Asset Capsule gets stuck on corners 0 Answers

PlayerPrefs Problem crashing with SetBool 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