added ladder script

This commit is contained in:
derek
2025-06-16 16:39:24 -05:00
parent be26131b39
commit 07ea71a3ed
9 changed files with 608 additions and 55 deletions

View File

@@ -1,39 +1,13 @@
extends Area3D
@onready var collision_midpoint: Node3D = $CollisionMidpoint
var player
var player_on_ladder = false
@onready var level_control = get_tree().current_scene
# Called when the node enters the scene tree for the first time.
func _ready():
pass
class_name Ladder
@onready var ladder_player_pos: Marker3D = $LadderPlayerPos
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
#if player != null:
#if player.is_climbing:
#hold_player()
func _on_body_entered(body):
if body.is_in_group("player"):
body.is_climbing = true
if body.global_position.y < collision_midpoint.global_position.y:
body.global_position.y += .2
#else:
#body.velocity = Vector3(0,0,0)
#body.global_position = Vector3(global_position.x,body.global_position.y,global_position.z)
func _on_body_entered(body: Node3D) -> void:
if body is Player:
body.start_ladder_climb(ladder_player_pos)
func _on_body_exited(body):
if body.is_in_group("player"):
body.is_climbing = false
player_on_ladder = false
body.velocity.y = .1
func hold_player():
var direction_to_ladder = player.global_position.direction_to(self.global_position)
player.velocity = Vector3(direction_to_ladder.x * 10,player.velocity.y,direction_to_ladder.z * 10)
func _on_body_exited(body: Node3D) -> void:
if body is Player:
body.end_ladder_climb()