enhancement: natural movement based off of N-1 and N frames displacement for velocity calc

This commit is contained in:
2025-10-20 21:33:49 -06:00
parent 4190112800
commit 38235be363
2 changed files with 4 additions and 4 deletions

View File

@@ -28,7 +28,7 @@ func _process(delta: float) -> void:
time_since_first_location = 0 time_since_first_location = 0
if Input.is_action_pressed("click"): 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"): elif Input.is_action_just_released("click"):
time_since_first_location += delta time_since_first_location += delta
@@ -36,14 +36,14 @@ func _process(delta: float) -> void:
if mouse_release_location.x < mouse_first_location.x: if mouse_release_location.x < mouse_first_location.x:
var distance = mouse_release_location.x - mouse_first_location.x var distance = mouse_release_location.x - mouse_first_location.x
velocity = (distance / velocity = (distance /
(velocity_coeffecient * time_since_first_location)) (velocity_coeffecient * delta))
draggable = false draggable = false
elif mouse_release_location.x > mouse_first_location.x: elif mouse_release_location.x > mouse_first_location.x:
var distance = abs(mouse_first_location.x var distance = abs(mouse_first_location.x
- mouse_release_location.x) - mouse_release_location.x)
velocity = (distance / velocity = (distance /
(velocity_coeffecient * time_since_first_location)) (velocity_coeffecient * delta))
draggable = false draggable = false
elif not draggable: elif not draggable:

View File

@@ -23,4 +23,4 @@ offset_top = 299.0
offset_right = 455.0 offset_right = 455.0
offset_bottom = 299.0 offset_bottom = 299.0
script = ExtResource("2_mej84") script = ExtResource("2_mej84")
velocity_coeffecient = 735 velocity_coeffecient = 220