Camera drag and object drag lock
This commit is contained in:
parent
d7302501f0
commit
eb67cf763a
2 changed files with 8 additions and 5 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue