Camera drag and object drag lock

This commit is contained in:
Rendo 2025-11-12 15:34:36 +05:00
commit eb67cf763a
2 changed files with 8 additions and 5 deletions

View file

@ -1,7 +1,8 @@
extends Camera3D extends Camera3D
const SENSITIVITY = 0.05 const SENSITIVITY = 0.01
func _input(event: InputEvent) -> void: func _input(event: InputEvent) -> void:
if Input.is_action_pressed("drag_camera") and event is InputEventMouseMotion: 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

View file

@ -9,7 +9,6 @@ func _mouse_enter() -> void:
func _mouse_exit() -> void: func _mouse_exit() -> void:
mouse_in = false mouse_in = false
dragged = false
func _process(delta: float) -> void: func _process(delta: float) -> void:
if dragged == false: if dragged == false:
@ -19,5 +18,8 @@ func _process(delta: float) -> void:
global_position = new_position global_position = new_position
func _input(event: InputEvent) -> void: func _input(event: InputEvent) -> void:
if mouse_in and event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT: if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
dragged = true if event.pressed else false if mouse_in and event.pressed:
dragged = true
if event.pressed == false:
dragged = false