Search Unity

Feature Request PointerLock unadjustedMovement

Discussion in 'Web' started by roka, May 12, 2023.

  1. roka

    roka

    Joined:
    Sep 12, 2010
    Posts:
    598
    hello,

    It will be cool to remove the mouse acceleration by default for WEBGL or to make it as option.

    https://web.dev/disable-mouse-acceleration/

    Code (JavaScript):
    1. function requestPointerLockWithUnadjustedMovement() {
    2.   const promise = myTargetElement.requestPointerLock({
    3.     unadjustedMovement: true,
    4.   });
    5.  
    6.   if (!promise) {
    7.     console.log("disabling mouse acceleration is not supported");
    8.     return;
    9.   }
    10.  
    11.   return promise
    12.     .then(() => console.log("pointer is locked"))
    13.     .catch((error) => {
    14.       if (error.name === "NotSupportedError") {
    15.         // Some platforms may not support unadjusted movement.
    16.         // You can request again a regular pointer lock.
    17.         return myTargetElement.requestPointerLock();
    18.       }
    19.     });
    20. }
    Thank you
     
    ThaBullfrog likes this.
  2. ThaBullfrog

    ThaBullfrog

    Joined:
    Mar 14, 2013
    Posts:
    49