fixed camera controls
This commit is contained in:
parent
cd62e12389
commit
d6a0911801
78 changed files with 4044 additions and 81 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue