fixed camera controls

This commit is contained in:
Luca 2024-11-17 13:06:55 +01:00
parent cd62e12389
commit d6a0911801
78 changed files with 4044 additions and 81 deletions

View file

@ -2,12 +2,11 @@ extends Control
var pressed: bool = false
var previous_position : Vector2 = Vector2.ZERO
var speed : float = 0.5
var delta_position: Vector2 = Vector2.ZERO
var damping_factor: float = 0.08
var damping_factor: float = 0.15
func _process(delta: float) -> void:
simulate_joystick_motion(JOY_AXIS_RIGHT_X, delta_position.x * delta * speed, 0)
simulate_joystick_motion(JOY_AXIS_RIGHT_X, delta_position.x, 0)
delta_position *= (1 - damping_factor)
func _gui_input(event: InputEvent) -> void:
@ -25,7 +24,7 @@ func _gui_input(event: InputEvent) -> void:
previous_position = Vector2.ZERO
if pressed and event is InputEventScreenDrag:
delta_position = clamp(previous_position - event.position, Vector2(-10, -10), Vector2(10, 10))
delta_position = previous_position - event.position
# finally update the previous position
previous_position = event.position