Skip to content

MovementData ​

Inherits: RefCounted

Container for movement information used to select appropriate animations Works with both navigation-driven and input-driven movement

Variables ​

Vector2movement_directionVector2.ZERO
floatmovement_speed0.0
boolis_movingfalse
boolis_walkingfalse # false = running
boolis_crouchedfalse
boolis_swimmingfalse
boolis_fallingfalse
boolis_turning_onlyfalse
boolis_in_combatfalse
boolhas_directional_effectfalse
Stringdirectional_effect_type""
Vector3entity_forwardVector3.FORWARD

Methods ​

MovementDatafrom_input_vector( input: Vector2, entity_forward: Vector3, is_walking: bool = false, is_crouched: bool = false ) static
MovementDatafrom_navigation( velocity: Vector3, entity_forward: Vector3, is_walking: bool = false ) static
MovementDatafrom_navigation_directional( velocity: Vector3, entity_forward: Vector3, is_walking: bool = false ) static
DirectionTypeget_primary_direction()

Enumerations ​

enum DirectionType ​

The options of direction type: none, forward, backward, left, right, forward left, forward right, backward left, backward right.

  • NONE = 0
  • FORWARD = 1
  • BACKWARD = 2
  • LEFT = 3
  • RIGHT = 4
  • FORWARD_LEFT = 5
  • FORWARD_RIGHT = 6
  • BACKWARD_LEFT = 7
  • BACKWARD_RIGHT = 8

Variable descriptions ​

Vector2 movement_direction = Vector2.ZERO ​

Movement vector (normalized, in entity's local space)

float movement_speed = 0.0 ​

How fast the entity moves.

bool is_moving = false ​

Movement states

bool is_walking = false # false = running ​

True when the entity walks.

bool is_crouched = false ​

True when the entity is crouched.

bool is_swimming = false ​

True when the entity swims.

bool is_falling = false ​

True when the entity falls.

bool is_turning_only = false ​

turning in place without movement

bool is_in_combat = false ​

Combat state

bool has_directional_effect = false ​

Directional movement effect

String directional_effect_type = "" ​

The kind of movement effect that moves the entity (empty when none).

Vector3 entity_forward = Vector3.FORWARD ​

Entity facing direction (for relative movement calculation)

Method descriptions ​

MovementData from_input_vector( input: Vector2, entity_forward: Vector3, is_walking: bool = false, is_crouched: bool = false ) ​

Create movement data from WASD input

MovementData from_navigation( velocity: Vector3, entity_forward: Vector3, is_walking: bool = false ) ​

Create movement data from navigation target

MovementData from_navigation_directional( velocity: Vector3, entity_forward: Vector3, is_walking: bool = false ) ​

Makes the data from the velocity of a path and the way the entity faces.

DirectionType get_primary_direction() ​

Get the primary movement direction as enum for animation selection