Hello, mouse input in HTML5/web exports produces large random jumps (both relative and screen_relative), both at the moment mouse capture mode is enabled, and randomly while it’s already active. This happens consistently and essentially makes it impossible to build 3D first or third person games. I’ve searched extensively online and understand that it’s harder to handle on web due to the underlying browser APIs being different. However, this issue has somehow been solved in other engines.
If anyone has knowledge on this subject or has already encountered this problem, I’d love to know what you did to work around it. Thank you.
func _unhandled_input(event):
if event is InputEventMouseMotion and d.device == "Computer":
if Input.is_mouse_button_pressed(MOUSE_BUTTON_RIGHT) or d.shiftLock:
d.camY = clamp(d.camY - event.screen_relative.y * defaultSensivity * 1.15, -1.2, 0.85)
d.camX -= event.screen_relative.x * defaultSensivity * 1.15
Update : While it work correctly on 500Hz mouse and below, anything above will still bug no matter my code or not. So it’s unplayable for high polling mouse. And without my controle damage code it’s unplayable on all mouse polling
This is not a bug I have ever seen, and my mouse is a high end gaming mouse that definitely can move faster than 500hz. I’ve never had an issue with a captured mouse pointer being responsive, and in fact typically have to make the mouse less responsive to make it work smoothly.
The issue is in your code, but you have not provided your full code. What you have provided seems overly complex for what you are trying to accomplish.
It looks like you’re trying to do a 3rd-person controller. Check out my Camera3D Plugin. It works fine in a browser export. You can either adapt the code or just use the plugin.
It’s not about my code, it’s about event jump. I can even show you the problem from an empty place just by printing the event. Unity used to have the same bug a few years ago but have been solved. Some popular web game that have been made with other engine can have the issue as well but it’s less common
Not in my code it doesn’t. Case in point: My game Prisoner 42 is a web game that has no Gameply stuttering with its 3rd person controller. If you don’t believe me, try it.
Again, you did not post full code, and I believe what you are seeing is a result of your code and not Godot’s performance.
I have also just tested it with my plugin, and I do not get numbers anywhere near to what you got.
What you say is just the event print, is demonstrably not just that. This code would be that.
I recommend you try changing screen_relative to relative in your code and see if the problem goes away. While the documentation recommends using screen_relative for mouse aiming, I have found in testing that relative provides smoother performance.
Empty place 100%. Nothing only one script and the html5 export. The bug occur.
What version of godot your game use ? In case you think thoses are natural movements, it’s pretty much impossible to go from 0 to 380+ in a single mouse movements without momentum @dragonforge-dev
Okay so i have published my game in Itch io to see. And yes in Itch io it look like it’s like 95% fixed. Small bumps when i lock but seem to stay consistent when i’m lock, nothing like inside godot. I’ll test a bit longer and mark your answer as a solution if the problem don’t persist. Thanks @dragonforge-dev