enhancement: natural movement based off of N-1 and N frames displacement for velocity calc
This commit is contained in:
@@ -28,7 +28,7 @@ func _process(delta: float) -> void:
|
||||
time_since_first_location = 0
|
||||
|
||||
if Input.is_action_pressed("click"):
|
||||
time_since_first_location += delta
|
||||
mouse_first_location = get_global_mouse_position()
|
||||
|
||||
elif Input.is_action_just_released("click"):
|
||||
time_since_first_location += delta
|
||||
@@ -36,14 +36,14 @@ func _process(delta: float) -> void:
|
||||
if mouse_release_location.x < mouse_first_location.x:
|
||||
var distance = mouse_release_location.x - mouse_first_location.x
|
||||
velocity = (distance /
|
||||
(velocity_coeffecient * time_since_first_location))
|
||||
(velocity_coeffecient * delta))
|
||||
draggable = false
|
||||
|
||||
elif mouse_release_location.x > mouse_first_location.x:
|
||||
var distance = abs(mouse_first_location.x
|
||||
- mouse_release_location.x)
|
||||
velocity = (distance /
|
||||
(velocity_coeffecient * time_since_first_location))
|
||||
(velocity_coeffecient * delta))
|
||||
draggable = false
|
||||
|
||||
elif not draggable:
|
||||
|
||||
@@ -23,4 +23,4 @@ offset_top = 299.0
|
||||
offset_right = 455.0
|
||||
offset_bottom = 299.0
|
||||
script = ExtResource("2_mej84")
|
||||
velocity_coeffecient = 735
|
||||
velocity_coeffecient = 220
|
||||
|
||||
Reference in New Issue
Block a user