Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Sl0thzy · Oct 06, 2016 at 01:55 AM · unity 5cursor

Cursor keeps being moved back to the center of the screen?

I have been trying to solve this for 3 days now and I have been unable to solve it myself. What is happening is when I open my inventory, my mouse is in theory supposed to be shown and unlocked. Now this almost works, except when I try to actually move my mouse around, it almost instantly gets moved straight to the center. I am using Unity version 5.4.0f3.

My code that does this (in the inventory script) is:

 if (isShown) { // If the inventory is opened
 
             Cursor.visible = true;
             Cursor.lockState = CursorLockMode.None;
 }

I have no other code that affects the cursor except for this in a separate script:

 if (inventory.isShown || pauseManager.isPaused) { // If inventory is opened or game is paused
         Cursor.visible = true;
         Cursor.lockState = CursorLockMode.None;
         } else {
             Cursor.lockState = CursorLockMode.None;
         }


Any help would be greatly appreciated ~

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 Bunny83 · Oct 06, 2016 at 02:58 AM

Well it soley depend on how you actually lock the cursor. Also what platform do you build for? WebGL for example has some restrictions how the cursor locking works.

Usually when you use CursorLockMode.Locked, just as the documentation says, it will "lock the cursor to the center of the screen".

Maybe you want to use CursorLockMode.Confined? However i'm not sure why it's a problem when the cursor is in the screen center after locking. That's how 90% of all FPS games work (HL, Quake and even Minecraft).

It's not quite clear from your question if you see the cursor elsewhere after unlocking. If that's the case it might be a bug either in the OS or Unity. Again, what platform are you build for? Do you actually test in the editor or in the actual build?

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 Sl0thzy · Oct 06, 2016 at 01:15 PM 0
Share

Currently this is all inside the editor and I am on WIndows 10. I need to use CursorLock$$anonymous$$ode.Locked for the purpose of bringing it back to moving the camera around for the purpose of FPS. I have tried confined ins$$anonymous$$d of none, but got a similar issue. I simply lock the cursor. If it makes a difference, I am currently using the Unity Standard Assets FPS controller on my player.

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

99 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 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 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 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 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

Turning curser on and off 0 Answers

Cursor Not Centered 0 Answers

Unity Cursor changing back 1 Answer

Cursor not getting centered 0 Answers

cursor visible not working please help 0 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