Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebGL Zoom Is Super Sensitive #13

Open
mattluard opened this issue Jan 26, 2025 · 1 comment
Open

WebGL Zoom Is Super Sensitive #13

mattluard opened this issue Jan 26, 2025 · 1 comment

Comments

@mattluard
Copy link

This is Unity's fault - in a WebGL build the mouse scroll wheel sensitivity is really high, far higher than in the editor. In practice this means that zooming in/out with the RTSCameraController launches you from fully zoomed in to fully zoomed out with the tiniest movement of the mouse scroll wheel.

Here's a thread from the Unity forums, which I mainly link to show that Unity aren't interested in fixing it, since it's a problem originally reported in 2016 and it's still present in Unity 6.

My quick and messy patch for this looks like so:

    internal void HandleZoomInput()
    {
        float zoomInput = _inputProvider.ZoomInput();
        if (zoomInput != 0)
        {
            float adjustedCameraZoomSpeed = CameraZoomSpeed;
	    #if !UNITY_EDITOR && UNITY_WEBGL
	    adjustedCameraZoomSpeed *= 0.01f;
	    #endif
            _currentCameraZoom -= zoomInput * adjustedCameraZoomSpeed;
            _currentCameraZoom = Mathf.Clamp(_currentCameraZoom, CameraZoomMin, CameraZoomMax);
            CancelTargetLock();
        }
    }

For me, this gets the mouse wheel more in line with what it's like in the editor.

Only an issue if WebGL is one of the targets you want to support, but in my testing, other than this, the camera controller works great!

@Nickk888SAMP
Copy link
Owner

Hi there!

Yes, I've noticed that as well while testing on my portfolio website. I thought that there's a weird bug in my code or something 😳

I'll look into this, even though WebGL builds are used very rarely, it still should work fine in my opinion 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants