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 thornekey · Mar 15, 2014 at 02:32 AM · c#camerarotatecamera-looktransform.rotate

Logical Camera errors...

Ok, so im having this error with my Camera script.. I know what the issue is juts not how to solve it. It orbits around the player, and if i orbit right, and then up a bit and then right again, it starts orbiting diagonally.

alt text this top view diagram shows the degree at which it can rotate around the player. So a full 360°.

alt text this front view diagram shows the degree at which it can rotate up and downwards whilst looking at the player. about 40°..

alt text as you can see this is what is occurring if i rotate right then up then right. If i do that i just want it to continue on a 'locked' axis.

     if (Input.GetKey(KeyCode.LeftArrow)) {
             transform.Rotate(0,Time.deltaTime * 100,0);
         }
                     
         else if (Input.GetKey(KeyCode.RightArrow)) {
             transform.Rotate(0,Time.deltaTime * -100,0);
         }    
         
         else if (Input.GetKey(KeyCode.UpArrow)) {
             transform.Rotate(Time.deltaTime * 100,0,0);
         }
                     
         else if (Input.GetKey(KeyCode.DownArrow)) {
             transform.Rotate(Time.deltaTime * -100,0,0);
         }

sorry if i havent explained it properly its hard. hopefully the pictures give you guys some idea of whats occurring.

2.png (915 B)
1.png (1.4 kB)
Comment
Add comment · Show 1
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 thornekey · Mar 15, 2014 at 08:23 AM 0
Share

bump please help

1 Reply

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

Answer by pako · Mar 15, 2014 at 09:57 AM

I don't understand 100%, but it seems to me that this happens because you are rotating the camera using local axis rather than world. Try specifying Space.World as the last parameter in your Rotate statements, see:

http://docs.unity3d.com/Documentation/ScriptReference/Transform.Rotate.html

e.g.

  if (Input.GetKey(KeyCode.LeftArrow)) {
 transform.Rotate(0,Time.deltaTime * 100,0, Space.World);
 }
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 thornekey · Mar 15, 2014 at 10:05 AM 0
Share

that has given me some crazy stuff. Ill try to explain better, basically if i rotate horizontally it will be (for example) (0,70,0) upward (10,0,0) so the final rotation will be (10,70,0) correct? yes. So now if i continue again on the horizontal rotation it will be slanted..

avatar image thornekey · Mar 15, 2014 at 10:06 AM 0
Share

hold on i have fixed it, i accidently put your solution on the vertical one. Thanks this has worked.

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

21 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

Related Questions

Rotate Camera on axis and X axis not working 1 Answer

How to make my camera only rotate on middle mouse click? 1 Answer

Having Trouble animating camera at start of game 0 Answers

How to rotate terrain or tilt it for z axis when play mode? (C#) just think of it as an object 0 Answers

Movement with camera and rotation of objects 1 Answer


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