1
Fork 0
mirror of https://github.com/Steffo99/hella-farm.git synced 2024-11-21 23:54:23 +00:00

Add fly/drop damps and cutoffs

This commit is contained in:
Lorenzo Rossi 2024-04-22 23:29:49 +02:00
parent bacbbb7ff0
commit c5d40c0e85
2 changed files with 14 additions and 4 deletions

View file

@ -9,8 +9,10 @@ signal fallen
@export var acceleration = 1250.0 @export var acceleration = 1250.0
@export var drag_damp = 0.4 @export var drag_damp = 0.4
@export var drop_damp = 0.05 @export var fly_damp = 0.045
@export var drop_epsilon = 16.0 @export var drop_damp = 0.2
@export var fly_cutoff = 400.0
@export var drop_cutoff = 16.0
var cursor: Cursor = null var cursor: Cursor = null
var falling: bool = false var falling: bool = false
@ -40,7 +42,12 @@ func _physics_process(delta: float) -> void:
velocity += gap * delta * acceleration velocity += gap * delta * acceleration
velocity *= 1.0 - drag_damp velocity *= 1.0 - drag_damp
else: else:
velocity *= 1.0 - drop_damp if velocity.length() >= fly_cutoff:
if falling and velocity.length() < drop_epsilon: velocity *= (1.0 - fly_damp)
else:
velocity *= (1.0 - drop_damp)
if falling and velocity.length() < drop_cutoff:
fall() fall()
move.emit(velocity * delta) move.emit(velocity * delta)

View file

@ -884,6 +884,9 @@ position = Vector2(56, -50)
[node name="Sheep" parent="." instance=ExtResource("9_qrqqu")] [node name="Sheep" parent="." instance=ExtResource("9_qrqqu")]
position = Vector2(-310, 166) position = Vector2(-310, 166)
[node name="Imp2" parent="." instance=ExtResource("10_yw228")]
position = Vector2(408, 225)
[node name="Imp" parent="." instance=ExtResource("10_yw228")] [node name="Imp" parent="." instance=ExtResource("10_yw228")]
position = Vector2(393, -137) position = Vector2(393, -137)