Skip to content

FollowingState ​

Inherits: ActionState < Resource

FollowingState represents when an entity is following another entity or position. Typically used for companion NPCs or pets following the player.

Description ​

Key features:

  • Follows target entity or specific position
  • Configurable follow distance and walk/run mode
  • Supports pet formation system
  • Transitions to combat when attacked

Variables ​

floatmin_follow_distance2.0
booluse_runningfalse
boolforce_walkingtrue

Methods ​

voidenter()
voidexit()
voidupdate( _delta: float )
voidset_follow_target( target: Node3D, distance: float = 2.0, walk: bool = true )
voidset_follow_position( position: Vector3, distance: float = 0.5, walk: bool = true )

Constants ​

  • float COMPANION_TELEPORT_DISTANCE = 40.0 - A companion this far from its leader (a loading, a teleport, a fall) is put next to it

Variable descriptions ​

float min_follow_distance = 2.0 ​

Min follow distance

bool use_running = false ​

Whether to run

bool force_walking = true ​

Whether to force walking

Method descriptions ​

void enter() ​

Called when entering the following state

void exit() ​

Called when exiting the following state

void update( _delta: float ) ​

Called every frame to update following behavior

void set_follow_target( target: Node3D, distance: float = 2.0, walk: bool = true ) ​

Set the target to follow

void set_follow_position( position: Vector3, distance: float = 0.5, walk: bool = true ) ​

Set a position to follow