Attach momentum to elevator

This commit is contained in:
2020-06-01 05:32:07 -04:00
parent 1980139acb
commit 3dd00eabd3
5 changed files with 43 additions and 2 deletions

View File

@ -0,0 +1,25 @@
extends Area2D
var player_node
func _ready():
connect("body_entered", self, "_on_body_enter")
connect("body_exited", self, "_on_body_exit")
set_process(false)
func _on_body_enter(body):
if body.has_method("user_input"):
player_node = body
set_process(true)
func _on_body_exit(body):
if body.has_method("user_input"):
body.floor_speed = Vector2.ZERO
set_process(false)
func _process(delta):
if get_parent().motion.y > 0:
player_node.floor_speed = get_parent().motion
else:
player_node.floor_speed = Vector2.ZERO