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
0
Question by j3sterX · Oct 18, 2013 at 09:34 AM · cameracamera rotaterotation axis

What other methods are there for locking rotation of an object?

I have an object that is the pivot point for a camera, so when the player presses a joystick, the camera should rotate around the point only on the x and the y axis. Every time I try editing this rotation, it causes a rotation on the z axis as well, but I need that to stay at a 0 rotation. I have tried adding a rigid body and locking it within the constraints, and I have tried hardcoding it in to the update function, but for some reason, it still wants to cause rotation on the z axis. Any help would be greatly appreciated.

Comment
Add comment · Show 4
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 robertbu · Oct 18, 2013 at 05:20 PM 0
Share

Is this an issue of what angles are expressed in the Inspector or are you seeing real physical rotation on the 'z' axis?

avatar image j3sterX · Oct 19, 2013 at 03:37 AM 0
Share

Actual rotation on the 'z' axis. I was, however, able to get this cleaned up a little bit, by un-parenting the camera. I learned that using C# and the Transform.Rotate function (due to the fact that I can't use transform.rotation.eulerangles.x += rotationamount) that the pivot is a local point that is between the parent and child of the game object. So now I have it set up as unparented from the pivot point, and then just rotates around that, but it's still trying to rotate around the 'z' axis as well.

avatar image robertbu · Oct 19, 2013 at 04:22 AM 0
Share

Without seeing the code and maybe a project, I don't know what is going on. But you have to be careful about how you interpret rotations in the inspector. Rotations are stored in Quaternions. Euler angles are derived out of the Quaternion, and the angle put in is not the angle back out. So for example, if you execute this code:

 transform.eulerAngles = Vector3(180,0,0);
 Debug.Log(transform.eulerAngles);

...you will see the output is (0,180,180). That is the same physical rotation, but represented differently. You code might have only rotated around the 'x' axes, but the Inspector will show a 'Z' rotation.

avatar image j3sterX · Oct 20, 2013 at 02:56 AM 0
Share

Hmm, I guess that's very possible, because I was unaware that it would rotate it on the z axis from that code. I was using the Transform.Rotate feature that is built into Unity Code. I guess I'll have to play with the numbers a bit more, but for what I'm doing right now to just build a demo, the RotateAround $$anonymous$$ethod that I described above is working well enough.

0 Replies

· Add your reply
  • Sort: 

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

14 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

Related Questions

Problem with Camera rotating 0 Answers

How to Math.f Clamp this 0 Answers

How do I make this Camera movement happen when I right click? 1 Answer

how can stop camera wrong spinning? 0 Answers

third person camera 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