Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(1 edit)

Thank you for the feedback :) Yes the mouse issue appears only in the browser version, the standalone are working correctly. I'll have to check in Godot documentation understand better, the mode MOUSE_MODE_CAPTURED doesn't seem enough to avoid the issue.

Ahhhh that makes total sense! I am also in Godot! I'm wondering how you're doing the rotation on the y axis. Are you doing something like rotation.y = get_viewport().get_mouse_position().x?

I didn't know if you could try something like this:

func _input(event):
    if event is InputEventMouseMotion:
        rotate_y(-event.relative.x * mouse_sensitivity)
        camera.rotate_x(-event.relative.y * mouse_sensitivity)

That's if you are using a mouse_sensitivity variable or something at the top. I'm not sure if you are, might be nice <3 Not sure if this helps at all or if this is how you are already doing it! I never designed a first-person camera view like this yet in Godot (only in Unity)!

It looks like what I'm currently doing, I just surrounded each of the rotation with a test to make it move only when the mouse event is different than 0 to not interfere with the gamepad controls.

var mouse_sensitivity: float = 0.005
func _input(event: InputEvent) -> void:
    if event is InputEventMouseMotion:
        if event.screen_relative.x < 0.0 or event.screen_relative.x > 0.0:
            global_rotation.y -= event.screen_relative.x * mouse_sensitivity
        if event.screen_relative.y < 0.0 or event.screen_relative.y > 0.0:
            camera_root.rotation.x -= event.screen_relative.y * mouse_sensitivity

But maybe I should better use the rotate method instead of setting the rotation property manually.

There is a note about this in the Godot documentation regarding the  Mouse and input coordinates I follow. But it seems even though the mouse is in capture mode, it still goes out of the window when playing in HTML. Maybe is there something to set in the Web export too.

Thanks for the input! (Input, haha)

(+1)

Ahhhh you're using screen_relative which is tied to screen space. Did you try using the relative property from the event? That uses the mouse movement deltas from the pointer instead!

I would definitely avoid using global_rotation every frame too! It can start acting wonky from my experience. Try using the rotate method there most definitely <3

rotate_y(-event.relative.x * mouse_sensitivity)

But yeah from the code, I'm seeing screen_relative being the main issue since that's screen-based!

Haha I love the pun by the way xD

(+1)

Thank you, I'll definitely try it!