To anyone stumbling on this post, remistorms’ answer was close to the desired effect, but I found it dampened large motions too much. Here’s what I did instead:
var x = Input.GetAxisRaw ("Mouse X");
var y = Input.GetAxisRaw ("Mouse Y");
if (Application.platform == RuntimePlatform.WebGLPlayer) {
x = MouseLook.DampenedMovement (x);
y = MouseLook.DampenedMovement (y);
}
x *= sensitivity; // your custom sensitivity value...
y *= sensitivity; // ...which may be user-adjustable
// define this function:
public static float DampenedMovement (float value) {
if (Mathf.Abs (value) > 1f) {
// best value for dampenMouse is 0.5 but better make it user-adjustable
return Mathf.Lerp (value, Mathf.Sign (value), dampenMouse);
}
return value;
}
Also note: sensitivity seems to vary by browser/OS. I only tested on Edge/Firefox/Chrome on Windows 10, and found that I had to multiply the original (standalone) sensitivity by 0.25 for Chrome and Edge, and about 0.5 for Firefox, to make it feel similar to standalone. Try to find a good default value and make it user-adjustable.
I was having the same issue, and the workaround that I found was this:
0.- To try the understand the problema, I did the follow excercise.
1.- Make a new project.
2.- Download Stantard FPS of Unity, Cinemachine and New Input System
3.- Create a new scene with a nested fps prefab.
4.- Create a floor and some props.
5.- Buils for HTML 5.
6.- Upload to your server or itch.io
The result is that, the DEFAULT value of FPS SCRIPT for the FPS prefab is too LARGE or HIGH for HTML.
Same problem, not sure if relevant but this extends to anything with a mouse scroll wheel input as well, where the sensitivity is waaaaaay over 2 times of what it would be in the unity editor
We have this problem with one of our team but not me. Me: Windows, Chrome, Edge browser. Mousewheel motion is the same as in editor. My team-mate, also on Windows, also using Chrome, the mousewheel is crazy fast in the game.
(Unity 2021.3.32)
The problem seems to be with ‘Mouse acceleration’ settings, that is used more by Mac users.
In Windows this setting can also be enabled but is called ‘Enhance pointer precision’.
Enabling this acceleration causes scrolling in WebGL builds to be crazy fast, disabling it ‘fixes’ the problem: