Wicked-Depths/ladder.gd

25 lines
513 B
GDScript

extends CharacterBody2D
func _process(delta):
var player = false
var the_player = get_parent().get_node("plr")
var overlap = $ladder.get_overlapping_bodies()
for i in overlap:
if i.name == "plr":
player = true
the_player = i
if player:
if Input.is_action_just_pressed("interact") or Input.is_action_just_pressed("ui_up") or Input.is_action_just_pressed("ui_down"):
the_player.ladder = self
the_player.on_ladder = true
elif the_player.ladder == self:
the_player.on_ladder = false