32 lines
614 B
GDScript
32 lines
614 B
GDScript
extends KinematicBody2D
|
|
|
|
var fall = false
|
|
export var fall_speed = 0.5
|
|
onready var startpos = position
|
|
onready var fall_timer = $FallTimer
|
|
onready var refresh_timer = $RefreshTimer
|
|
|
|
func _physics_process(delta):
|
|
if fall:
|
|
position.y += fall_speed
|
|
|
|
func _on_Area2D_area_entered(area):
|
|
if area.is_in_group("player"):
|
|
fall_timer.start()
|
|
|
|
|
|
func _on_VisibilityNotifier2D_screen_exited():
|
|
position = startpos
|
|
fall = false
|
|
|
|
func _on_RefreshTimer_timeout():
|
|
position = startpos
|
|
fall = false
|
|
|
|
func _on_FallTimer_timeout():
|
|
fall = true
|
|
refresh_timer.start()
|
|
|
|
|
|
func _on_Area2D_area_exited(area):
|
|
fall_timer.stop()
|