YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
26 stars 8 forks source link

In-Game: [HTML5] window_mouse_set_locked() no longer works in 2024.6 #6824

Closed gm-bug-reporter[bot] closed 2 months ago

gm-bug-reporter[bot] commented 3 months ago

Description

Basically, the function "window_mouse_set_locked()" no longer works on the HTML5 export. It did a few months ago. I'm using it for 3D camera movement so the player can look all around. I went back to other test projects where it did work previously, and it no longer worked with those either. All I'm doing is putting "window_mouse_set_locked(true);" into a create event then never touching it again. I can still move the camera around, but the mouse will be visible and just leave the game area.

Steps To Reproduce

You can open a blank project, make an object with "window_mouse_set_locked(true);" in it's create event, and put it into the room. Make sure to include a "press escape to game_end" type thing in the step event! Running it on Windows locks the mouse as it should, running on HTML5 does not do anything to the mouse. Works on GX.Games though.

Which version of GameMaker are you reporting this issue for?

IDE v2024.6.2.162 Runtime v2024.6.1.208

Which operating system(s) are you seeing the problem on?

Windows 10.0.19045.0

Which platform(s) are you seeing the problem on?

HTML5

6d210a14-5877-4890-8160-84e0ae4c82fb

pkraif commented 2 months ago

The attached project tries to enable mouse lock in the Create event, which shouldn't work, since browsers require the user to first interact (click) with the canvas to be able to enable mouse lock. So this function is best used in a mouse press event or in Step using

if (mouse_check_button_pressed(mb_left))
{
    window_mouse_set_locked(true);
}

otherwise it won't do anything. We should get the manual page for the function updated to mention this. @YYBartT @gurpreetsinghmatharoo

I've tested the project with this little change in IDE v2024.8.0.169 Runtime v2024.8.0.216 and mouse lock works fine.

YYBartT commented 2 months ago

Added a note to the window_mouse_set_locked() manual page.