Skip to content

LadderInteraction ​

Inherits: InteractableObjectInteraction < Interaction < Resource

Ladder interaction - climbing system using Path3D Discovers scene structure by name: "LadderPath", "StartMarker", "EndMarker"

Properties ​

floatclimb_speed3.0
boolallow_multiple_climbersfalse
boollock_entity_controlstrue

Variables ​

Path3Dladder_path
Marker3Dstart_marker
Marker3Dend_marker
LadderStatecurrent_stateLadderState.IDLE
Array[Dictionary]active_climbers[]
floatladder_length0.0

Methods ​

voidsetup_for_interactable_objects( interactable: InteractableObject )
boolcan_interact( player: Player )
voidstart_interaction( player: Player )
voidend_interaction()
Stringget_interaction_prompt()
voidstart_climbing( entity: Entity, direction: ClimbDirection )
voidinterrupt_climbing( entity: Entity )
voidset_ladder_state( new_state: LadderState )
boolis_entity_climbing( entity: Entity )
floatget_climb_progress( entity: Entity )
Dictionarysave_state()
voidload_state( state: Dictionary )
voidcleanup()

Signals ​

climb_started( entity: Entity, direction: ClimbDirection ) ​

Emitted when an entity starts to climb: the entity and the direction.

climb_finished( entity: Entity, direction: ClimbDirection ) ​

Emitted when an entity reaches the end of the ladder.

climb_interrupted( entity: Entity ) ​

Emitted when a climb is interrupted before the end.

Enumerations ​

enum ClimbDirection ​

Which way an entity climbs: up (start to end of the path) or down.

  • UP = 0 - Climbing from start to end of path
  • DOWN = 1 - Climbing from end to start of path

enum LadderState ​

The states of a ladder: idle (nobody climbs), in use or broken.

  • IDLE = 0 - No one is climbing
  • IN_USE = 1 - Someone is currently climbing
  • BROKEN = 2 - Ladder is broken/unusable

Property descriptions ​

Ladder Setup

float climb_speed = 3.0 ​

Speed at which entities climb (units per second)

bool allow_multiple_climbers = false ​

Whether ladder can be used simultaneously by multiple entities

bool lock_entity_controls = true ​

(kept for older scenes: the controls of a climbing entity are always locked, the controller ignores input while is_climbing is set)

Variable descriptions ​

Path3D ladder_path ​

Path3D defining the ladder route (found by name "LadderPath")

Marker3D start_marker ​

Start point marker (found by name "StartMarker")

Marker3D end_marker ​

End point marker (found by name "EndMarker")

LadderState current_state = LadderState.IDLE ​

The state of the ladder now.

Array[Dictionary] active_climbers = [] ​

{entity: Entity, direction: ClimbDirection, progress: float, tween: Tween}

float ladder_length = 0.0 ​

The length of the path of the ladder.

Method descriptions ​

void setup_for_interactable_objects( interactable: InteractableObject ) ​

Sets the ladder up on its object: finds the nodes it needs and applies its starting state.

bool can_interact( player: Player ) ​

Can the player use the ladder now (in range, the object is not broken, the requirements are met)?

void start_interaction( player: Player ) ​

The player uses the ladder.

void end_interaction() ​

Does nothing: the climb goes on after the interaction ends.

String get_interaction_prompt() ​

The text of the prompt above the object for its state now ("Open", "Climb" ...).

void start_climbing( entity: Entity, direction: ClimbDirection ) ​

Makes an entity climb the ladder in a direction. Does nothing when it already climbs it.

void interrupt_climbing( entity: Entity ) ​

Stops the climb of an entity.

void set_ladder_state( new_state: LadderState ) ​

Sets the state of the ladder.

bool is_entity_climbing( entity: Entity ) ​

Is the entity climbing this ladder?

float get_climb_progress( entity: Entity ) ​

How far along the ladder the entity is (0 to 1).

Dictionary save_state() ​

The state of the ladder for a save.

void load_state( state: Dictionary ) ​

Restores the state of the ladder from a save.

void cleanup() ​

Gives its timers back and clears what it holds (the object is going away).