falling block has a delay before falling

This commit is contained in:
pennyrigate 2023-01-15 00:22:04 -05:00
parent 124b5e16aa
commit c3f32de2df
7 changed files with 216 additions and 40 deletions

View file

@ -3,16 +3,27 @@ extends KinematicBody2D
var fall = false
export var fall_speed = 0.5
onready var startpos = position
onready var timer = $Timer
func _physics_process(delta):
if fall:
position.y += fall_speed
Debug.print($Timer.get_time_left())
func _on_Area2D_area_entered(area):
if area.is_in_group("player"):
fall = true
$Timer.start()
func _on_VisibilityNotifier2D_screen_exited():
position = startpos
fall = false
func _on_Timer_timeout():
fall = true
func _on_Area2D_area_exited(area):
$Timer.stop()