• 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 monroe · Nov 12, 2013 at 03:34 AM · lockmouse looklock-cursormouse aim

How to make the basic mouselook look all the way up and down?

I am a noob who downloaded unity for practice, and right now I tweak the basic codes to practice and I cant seem to make the fps controller (mouselook) to look all the way up, or all the way down, and its bugging me.

I changed this,

 public float minimumY = -90F;
 public float maximumY = 90F;

but it didn't make any difference. I even changed it to 180, if someone posts an answer can you also tell me how it works?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by aldonaletto · Nov 12, 2013 at 03:45 AM

Maybe you're modifying the wrong MouseLook: there are two scripts, one attached to the player (which only rotates horizontally) and the other attached to the camera - this one rotates the camera up and down, and checks minimumY and maximumY. Anyway, these limits should never reach -90/90 degrees: a kind of "division by zero" condition appears when the angle is too close to -90 or 90 degrees, and the camera gets crazy (even worse if passing these limits).

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 monroe · Nov 13, 2013 at 01:19 AM 0
Share

thank you, that helped!

avatar image
0

Answer by RealEfrain12 · Nov 22, 2020 at 02:30 AM

To look Up and Down I have this as my looking up and down script

     public float mouseSensitivity = 100f;
     float xRotation = 0f;
    
     void Start()
     {
         Cursor.lockState = CursorLockMode.Locked;
     }
    
     void Update()
     {
         
         float MouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
         xRotation -= MouseY;
         xRotation = Mathf.Clamp(xRotation, -90, 90);
         transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
     }

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 Eno-Khaon · Nov 22, 2020 at 03:17 AM 0
Share

You shouldn't multiply mouse input by Time.deltaTime. This causes a per-frame input to unexpectedly be reduced based on current framerate.

For constant-value input, such as held keys, it makes sense. For input that varies on a per-frame basis, such as mouse movement, you want to use it as-is.

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

19 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

Related Questions

im trying to make my mouse lockstate.locked during gameplay and lockstate.confined when game is over 0 Answers

Cursor Problem / Toggle Lock and Unlock 0 Answers

Locking and Unlocking a cursor... 2 Answers

Mouse lock 2 Answers

How do I lock and then unlock the cursor using the same key? 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