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
1
Question by Aceria · May 07, 2013 at 11:49 AM · cameraverticallocked

Camera locks on y axis on start

I've had this problem for a while now and it's very slowly making me go mad. We made a game and everything works fine, except the camera. When you open the game you press Start with your mouse, the camera will now pan down to a first person position. The mouse is hidden and the player should now be able to move the camera around as you expect. The only problem is that it is locked on the y axis (horizontal movement works just fine). Here's the script I'm using (it's the default MouseLook script with some minor additions):

 function Update(){
     if(!menu.start && !menu.isPaused || menu.isAnimating){
         Screen.showCursor = false;
         Screen.lockCursor = true;
     }
     else if(menu.isPaused){
         Screen.showCursor = true;
         Screen.lockCursor = false;
     }
 
     if(!menu.start && !menu.isPaused && !menu.isAnimating){
         if(axes == RotationAxes.MouseXAndY){
             var rotationX : float = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX;
             
             rotationY += Input.GetAxis("Mouse Y") * sensitivityY * invertedcam;
             rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
             
             transform.localEulerAngles = Vector3(-rotationY, rotationX, 0);
         }
         else if(axes == RotationAxes.MouseX){
             transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityX, 0);
         }
         else{
             rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
             rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
             
             transform.localEulerAngles = Vector3(-rotationY, transform.localEulerAngles.y, 0);
         }
     }
 }

You can play the game here: http://www.kongregate.com/games/Aceria620/fragments-of-him The bug occurs once you press Start and the camera pans down.

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
1
Best Answer

Answer by aldonaletto · May 07, 2013 at 12:54 PM

From your web game, it seems that you've forgot to initialize invertedcam - this way it starts with 0, and no vertical movement occurs. Once I set the Y direction in the menu, the camera vertical control started to work.

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 Aceria · May 07, 2013 at 01:11 PM 0
Share

I didn't even think of that, but that makes 100% sense. Thanks a lot!

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

13 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

Related Questions

Make a 2D Camera vertically stationary? 0 Answers

How to restrict camera rotation to vertical axis? 2 Answers

camera horizontal movement 0 Answers

How to make camera position relative to a specific target. 1 Answer

Raycast - Making ray shoot down vertically -Vector.up 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