Hi, I’m one of the Unity developers working on 3D Aim Trainer, a browser based aim trainer. It’s important to us that we can deliver a smooth experience for all of our users. Unfortunately, some of our users have reported erratic mouse movement, making it hard for them to effectively train their aiming skills. We’ve set up some tests and have managed to reproduce the issue ourselves.
Issue:
Input.GetAxis() and Input.GetAxisRaw() will frequently produce incorrect values for both “Mouse X” and “Mouse Y” in WebGL builds when running on lower end systems using mice with a high polling rate (500Hz and up). We have not been able to test whether this issue is unique to WebGL or if it occurs in standalone windows builds as well. The issue occurs only when the cursor is locked and causes the camera controller in our project to randomly rotate several degrees across a single frame, effectively making the camera skip.
As the setup required to reproduce this issue requires specific hardware and / or a virtual machine, I’ve also recorded a video showcasing the issue which you can find in the google drive link at the bottom of the post.
Steps to reproduce:
- Visit the sample project page (itch.io) on a lower end system, using a mouse with a high polling rate. Target framerate should be right around 60 or a little below. In our tests we used an Asus Vivobook S15 using an Intel i3-8130U with built in graphics. A virtual machine with a similar setup may work too, though we haven’t tested this. As for the mouse, we used a Logitech G900 and a Corsair Ironclaw, both set to 1000Hz.
- Press ‘P’ to lock the cursor and confirm it is locked.
- Move the mouse left and right in long smooth motions
- If the setup is correct, you should notice occasional skips in the camera movement. The absolute value of Input.GetAxisRaw(“Mouse X”) is also displayed on the Y axis in the graph along the bottom of the screen, and will show spikes coinciding with these camera skips.
Notes:
- The problem seems to be directly linked to polling rates, as the frequency of these skips decreased alongside the polling rate. At 1000Hz the skips were most frequent, with a slight decrease in frequency at 500Hz, and with the issue being all but gone at 250Hz and 125Hz.
- We noticed the same issue being present in other WebGL games; most notably in krunker.io, one of the leading WebGL-based first person shooters. This seems to indicate it’s not unique to our project but rather caused by an external factor.
Is this an issue specific to Unity / WebGL, or is there something wrong with the way we’ve implemented this? Can we do something to fix / mitigate this issue in our project? This is affecting a fair amount of our users and we would like to be able to offer them a smooth experience without having to compromise on their polling rate.
You can check out the source project along with a video showcasing the issue in our trainer here: google drive.