37 lines
802 B
GDScript3
37 lines
802 B
GDScript3
|
extends CharacterBody2D
|
||
|
|
||
|
|
||
|
@export var enabled = false
|
||
|
@export var fail = false
|
||
|
|
||
|
func _physics_process(delta):
|
||
|
if not enabled:
|
||
|
self.visible = false
|
||
|
return
|
||
|
self.visible = true
|
||
|
var plr = get_parent().get_node("plr")
|
||
|
if plr.is_on_floor() or fail:
|
||
|
fail = false
|
||
|
position = plr.position + Vector2(0,60)
|
||
|
else:
|
||
|
position.x = plr.position.x
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
func _on_area_2d_body_shape_entered(body_rid, body, body_shape_index, local_shape_index):
|
||
|
if not enabled:
|
||
|
return
|
||
|
if body.name == "plr":
|
||
|
body.can_move = false
|
||
|
body.on_ladder = false
|
||
|
body.wall = "none"
|
||
|
body.airjump = false
|
||
|
var tweener = get_tree().create_tween()
|
||
|
$AudioStreamPlayer.play()
|
||
|
tweener.tween_property(body,"position",get_parent().get_node("CheckPoints").current.position,1)
|
||
|
await tweener.finished
|
||
|
body.can_move = true
|
||
|
|