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
3
Question by TimRoss · Aug 30, 2016 at 09:46 AM · webglcursor

WebGL Cursor Lock not centering

When the game is run in WebGL in browser. Cursor.lockState = CursorLockMode.Locked does not work. It does not want to lock the cursor in the center of the screen. It locks the cursor, but it only locks to the last place the cursor was before being locked. for example: In Firefox, before locking the cursor, a pop up appears in the top left of the screen which says: "Would you like the pointer to be hidden on this site?", if I click "Hide pointer", the cursor will lock to the position of where "Hide pointer" button was. This happens in: Unity 5.2.1f1, Unity 5.2.3.f1, Unity 5.3.5f1, Unity 5.4.0f3

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
0

Answer by Bunny83 · Aug 30, 2016 at 11:11 AM

I'm pertty sure that's a limitation of the browser itself and the Lock API. It only allows to lock the cursor in place. Moving the cursor would mean a website could literally control the clients mouse position on screen. This can be a security issue. So they only allow to lock it in place.

There's nothing Unity can do about it if it's a browser / sandbox limitation. Personally i'm glad that a website can't move my cursor around ^^.

The old Unity webplayer was a different story. Since the webplayer itself was a native application it can do anything on the client PC (moving mouse, format hdds ^^). Though there the security was provided by Unity itself. While the webplayer could in theory move the pointer wherever it want, it only allowed to center it on the webplayer context. Direct browser APIs have to be much more restrictive.

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 TimRoss · Aug 30, 2016 at 02:33 PM 0
Share

Cursor.lockState = CursorLock$$anonymous$$ode.Locked is meant to lock the cursor and center it. like it says here: https://docs.unity3d.com/$$anonymous$$anual/webgl-cursorfullscreen.html why would it not center it in WebGL? how can a person play a FPS game in WebGL if the cursor is not centered on screen?

avatar image Bunny83 TimRoss · Aug 31, 2016 at 12:47 AM 0
Share

Huh? The actual position of the hardware mouse position doesn't matter at all.... For an FPS game all you need is the mouse delta movement which you get without any problems.

Have a look at the official $$anonymous$$ouse lock demo for HT$$anonymous$$L5. The circle acts like a virual cursor even though the hardware cursor is locked in place.

An FPS game doesn't have a "cursor". You usually have a crosshair and this isn't drawn at the mouse position but at the screen center.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

WebGL Mouse spawn 0 Answers

How to use CursorLockMode in webGL 0 Answers

How to lock cursor in WebGL 1 Answer

Why does my cursor image have artifacts in WebGL? 2 Answers

Mouse won't unlock in WebGL build but does in the editor 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