From eb67cf763a5656876904625274e5158d0e3181c7 Mon Sep 17 00:00:00 2001 From: Rendo Date: Wed, 12 Nov 2025 15:34:36 +0500 Subject: [PATCH] Camera drag and object drag lock --- src/draggable_camera.gd | 5 +++-- src/draggable_object.gd | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/draggable_camera.gd b/src/draggable_camera.gd index 2564f07..6c89dae 100644 --- a/src/draggable_camera.gd +++ b/src/draggable_camera.gd @@ -1,7 +1,8 @@ extends Camera3D -const SENSITIVITY = 0.05 +const SENSITIVITY = 0.01 func _input(event: InputEvent) -> void: if Input.is_action_pressed("drag_camera") and event is InputEventMouseMotion: - global_position += get_ * Vector3(event.relative.x,event.relative.y,0) + global_position -= global_basis.x * event.relative.x * SENSITIVITY + global_position += global_basis.y * event.relative.y * SENSITIVITY diff --git a/src/draggable_object.gd b/src/draggable_object.gd index 5f25b4b..002a75c 100644 --- a/src/draggable_object.gd +++ b/src/draggable_object.gd @@ -9,7 +9,6 @@ func _mouse_enter() -> void: func _mouse_exit() -> void: mouse_in = false - dragged = false func _process(delta: float) -> void: if dragged == false: @@ -19,5 +18,8 @@ func _process(delta: float) -> void: global_position = new_position func _input(event: InputEvent) -> void: - if mouse_in and event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT: - dragged = true if event.pressed else false + if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT: + if mouse_in and event.pressed: + dragged = true + if event.pressed == false: + dragged = false