From ffee63dc57f0c99518fb2b7bb7ae0a7224aede9c Mon Sep 17 00:00:00 2001 From: null Date: Tue, 12 May 2026 17:19:34 -0500 Subject: [PATCH] feat: change camera rotation to be always active when mouse is captured --- game/scenes/Characters/location_player.gd | 18 +++++++----------- game/scenes/Interaction/RadialCommandMenu.gd | 2 ++ game/scenes/UI/start_screen.gd | 1 + game/scenes/player.gd | 18 +++++++----------- 4 files changed, 17 insertions(+), 22 deletions(-) diff --git a/game/scenes/Characters/location_player.gd b/game/scenes/Characters/location_player.gd index 9948e22..9093129 100644 --- a/game/scenes/Characters/location_player.gd +++ b/game/scenes/Characters/location_player.gd @@ -19,7 +19,6 @@ const FIREBALL_SPAWN_UP_OFFSET := 1.2 var mouse_sensitivity := 0.005 var rotation_x := 0.0 var rotation_y := 0.0 -var cameraMoveMode := false var current_number_of_jumps := 0 var _pending_mouse_delta := Vector2.ZERO var _last_move_forward := Vector3(0, 0, 1) @@ -86,12 +85,13 @@ func _ready() -> void: _last_move_right = right.normalized() _vehicle_collision_layer = collision_layer _vehicle_collision_mask = collision_mask + Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) func _integrate_forces(state): if _in_vehicle: linear_velocity = Vector3.ZERO return - if cameraMoveMode and _pending_mouse_delta != Vector2.ZERO: + if _pending_mouse_delta != Vector2.ZERO: rotation_x -= _pending_mouse_delta.y * mouse_sensitivity rotation_y -= _pending_mouse_delta.x * mouse_sensitivity rotation_x = clamp(rotation_x, deg_to_rad(-90), deg_to_rad(90)) @@ -156,20 +156,16 @@ func _input(event): phone_visible = !phone_visible if phone: phone.visible = phone_visible + if phone_visible: + Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) + else: + Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) return if _in_vehicle: return - if event is InputEventMouseButton: - if event.button_index == MOUSE_BUTTON_MIDDLE: - if event.pressed: - cameraMoveMode = true - Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) - else: - cameraMoveMode = false - Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) - if event is InputEventMouseMotion and cameraMoveMode: + if event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED: _pending_mouse_delta += event.relative if event is InputEventMouseButton and event.pressed: diff --git a/game/scenes/Interaction/RadialCommandMenu.gd b/game/scenes/Interaction/RadialCommandMenu.gd index ef4f2e6..f11e014 100644 --- a/game/scenes/Interaction/RadialCommandMenu.gd +++ b/game/scenes/Interaction/RadialCommandMenu.gd @@ -17,8 +17,10 @@ func _toggle_menu(): # Center the menu on the mouse or screen global_position = get_viewport().get_mouse_position() _animate_menu(true) + Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) else: _animate_menu(false) + Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) func _arrange_buttons(): var buttons = get_children().filter(func(child): return child is Control) diff --git a/game/scenes/UI/start_screen.gd b/game/scenes/UI/start_screen.gd index 4e4c57b..2f609cf 100644 --- a/game/scenes/UI/start_screen.gd +++ b/game/scenes/UI/start_screen.gd @@ -10,6 +10,7 @@ const PLAYGROUND_SCENE := "res://scenes/Levels/level.tscn" func _ready(): _register_focus_sounds() _update_login_button() + Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) func _register_focus_sounds() -> void: var button_container := $MarginContainer/CenterContainer/ContentVBox/VBoxContainer diff --git a/game/scenes/player.gd b/game/scenes/player.gd index d9dc2bb..4d8076b 100644 --- a/game/scenes/player.gd +++ b/game/scenes/player.gd @@ -19,7 +19,6 @@ const FIREBALL_SPAWN_UP_OFFSET := 1.2 var mouse_sensitivity := 0.005 var rotation_x := 0.0 var rotation_y := 0.0 -var cameraMoveMode := false var current_number_of_jumps := 0 var _pending_mouse_delta := Vector2.ZERO var _last_move_forward := Vector3(0, 0, 1) @@ -86,12 +85,13 @@ func _ready() -> void: _last_move_right = right.normalized() _vehicle_collision_layer = collision_layer _vehicle_collision_mask = collision_mask + Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) func _integrate_forces(state): if _in_vehicle: linear_velocity = Vector3.ZERO return - if cameraMoveMode and _pending_mouse_delta != Vector2.ZERO: + if _pending_mouse_delta != Vector2.ZERO: rotation_x -= _pending_mouse_delta.y * mouse_sensitivity rotation_y -= _pending_mouse_delta.x * mouse_sensitivity rotation_x = clamp(rotation_x, deg_to_rad(-90), deg_to_rad(90)) # Prevent flipping @@ -164,20 +164,16 @@ func _input(event): phone_visible = !phone_visible if phone: phone.visible = phone_visible + if phone_visible: + Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) + else: + Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) return if _in_vehicle: return - if event is InputEventMouseButton: - if event.button_index == MOUSE_BUTTON_MIDDLE: - if event.pressed: - cameraMoveMode = true - Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) - else: - cameraMoveMode = false - Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) - if event is InputEventMouseMotion and cameraMoveMode: + if event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED: _pending_mouse_delta += event.relative if event is InputEventMouseButton and event.pressed: