extends Area3D class_name LevelBounds var level_collision_shapes : Array[CollisionShape3D] var check_collision = true func _ready() -> void: SignalBus.player_exiting_tree.connect(player_exiting_tree) for i in get_children(): if i is CollisionShape3D: level_collision_shapes.append(i) func _on_body_exited(body: Node3D) -> void: if check_collision == true: var level_control = get_tree().current_scene if level_control.gamemode.die_on_leaving_bounds == true: get_tree().current_scene.die() else: body.velocity = Vector3.ZERO body.global_position = body.last_ground_pos + Vector3(0,.1,0) func toggle_collision(collision_state): check_collision = collision_state if level_collision_shapes != null and level_collision_shapes != []: for i in level_collision_shapes: i.disabled = collision_state func player_exiting_tree(): toggle_collision(false)