EntityAnimationPlayer ​
Inherits: AnimationPlayer
EntityAnimationPlayer A specialized AnimationPlayer for game entities with robust animation state management.
Variables ​
bool | animations_blocked | false |
bool | animations_death_blocked | false |
String | current_stance_tag | "" # Animation name from WeaponClassDefinition.stance_tag |
bool | current_combat_mode | false |
Dictionary | fallback_chains | { ... } |
ChronoManager | chrono_manager |
Methods ​
void | setup_animations( system_hub: GameHost.SystemHub, entity_data: EntityDefinition ) |
void | setup_animation_tree( tree_resource_path: String = DEFAULT_TREE_PATH ) |
void | set_free_movement_look( air: bool, pose: String = "" ) |
void | set_free_vertical_motion( fraction: float ) |
void | play_movement( movement_data: MovementData ) |
void | play_turning_animation( turn_direction: float, is_crouched: bool = false, is_swimming: bool = false ) |
void | set_turn_direction( turn_direction: float ) |
void | stop_turning_animation() |
void | play_casting_animation( ability_selection: AnimationSelectionAbility, weapon_type: String = "" ) |
void | play_ability_animation( ability_selection: AnimationSelectionAbility, weapon_type: String = "" ) |
void | stop_casting_animation() |
void | stop_ability_animation() |
void | cancel_casting_animation() |
void | stop_upper_body_animation() |
void | play_social_animation( social_selection: AnimationSelectionSocial, context: String = "" ) |
void | play_jump_animation() |
void | play_falling_animation() |
void | play_land_animation( impact_level: int ) |
void | play_combat_animation( animation_type: String, weapon_type: String = "" ) |
bool | play_trigger_animation( slots: PackedStringArray, weapon_tag: String = "" ) |
bool | play_status_effect_start_animation( status_name: String, speed: float = 1.0 ) |
bool | play_status_effect_loop_animation( status_name: String, speed: float = 1.0 ) |
bool | play_status_effect_end_animation( status_name: String, speed: float = 1.0 ) |
void | stop_status_effect_animation() |
bool | has_status_effect_animation( status_name: String, phase: String ) |
float | get_status_effect_animation_duration( status_name: String, phase: String ) |
void | play_block_animation( weapon_type: String = "" ) |
bool | play_profile_clip( weapon_tag: String, role: String ) |
void | play_dodge_animation( weapon_type: String = "" ) |
void | play_hit_animation( weapon_type: String = "" ) |
void | play_equipment_animation( action: String, weapon_type: String ) |
void | play_sheathe_animation( weapon_type: String ) |
void | play_unsheathe_animation( weapon_type: String ) |
void | play_death_animation() |
void | reset_from_death() |
void | set_stance_tag( stance_tag: String ) |
void | enter_combat_mode() |
void | exit_combat_mode() |
void | play_interaction_animation( interaction_type: String ) |
void | cleanup_timers() |
bool | is_animation_almost_complete() |
Signals ​
animation_motion_sound_trigger( message: String ) ​
Signal emitted when an animation should trigger a sound effect
Enumerations ​
enum AnimationName ​
Every animation slot the player knows (idle, walk, run, turn, jump, fall, swim, combat, death ...). Each slot is mapped to a real animation of the model by the animation map.
- NONE =
0 - IDLE_STANDING =
1 - IDLE_CROUCH =
2 - IDLE_SWIM =
3 - WALK_F =
4 - WALK_B =
5 - WALK_L =
6 - WALK_R =
7 - WALK_FL =
8 - WALK_FR =
9 - WALK_BL =
10 - WALK_BR =
11 - CROUCH_WALK_F =
12 - CROUCH_WALK_B =
13 - CROUCH_WALK_L =
14 - CROUCH_WALK_R =
15 - CROUCH_WALK_FL =
16 - CROUCH_WALK_FR =
17 - CROUCH_WALK_BL =
18 - CROUCH_WALK_BR =
19 - RUN_F =
20 - RUN_B =
21 - RUN_L =
22 - RUN_R =
23 - RUN_FL =
24 - RUN_FR =
25 - RUN_BL =
26 - RUN_BR =
27 - SPRINT_F =
28 - SPRINT_B =
29 - SPRINT_L =
30 - SPRINT_R =
31 - SPRINT_FL =
32 - SPRINT_FR =
33 - SPRINT_BL =
34 - SPRINT_BR =
35 - STRAFE_L =
36 - STRAFE_R =
37 - STRAFE_LF =
38 - STRAFE_LB =
39 - STRAFE_RF =
40 - STRAFE_RB =
41 - TURN_STANDING_90_L =
42 - TURN_STANDING_90_R =
43 - TURN_STANDING_180_L =
44 - TURN_STANDING_180_R =
45 - TURN_CROUCH_90_L =
46 - TURN_CROUCH_90_R =
47 - TURN_CROUCH_180_L =
48 - TURN_CROUCH_180_R =
49 - JUMP_IDLE =
50 - JUMP_RUNNING =
51 - FALL_START =
52 - FALL_LOOP =
53 - LAND_SOFT =
54 - LAND_MEDIUM =
55 - LAND_HARD =
56 - SWIM_F =
57 - SWIM_B =
58 - SWIM_L =
59 - SWIM_R =
60 - SWIM_FL =
61 - SWIM_FR =
62 - SWIM_BL =
63 - SWIM_BR =
64 - COMBAT_IDLE_UNARMED =
65 - COMBAT_IDLE_SHIELD =
66 - COMBAT_IDLE_DUAL_WIELD =
67 - COMBAT_IDLE_OFF_HAND =
68 - COMBAT_IDLE_ONE_HAND =
69 - COMBAT_IDLE_TWO_HAND =
70 - COMBAT_IDLE_RANGED_WEAPON =
71 - COMBAT_IDLE_BOW =
72 - COMBAT_IDLE_POLEARM =
73 - BLOCK_UNARMED =
74 - BLOCK_SHIELD =
75 - BLOCK_DUAL_WIELD =
76 - BLOCK_OFF_HAND =
77 - BLOCK_ONE_HAND =
78 - BLOCK_TWO_HAND =
79 - BLOCK_RANGED_WEAPON =
80 - BLOCK_BOW =
81 - BLOCK_POLEARM =
82 - BLOCK_CASTING =
83 - DODGE =
84 - HIT =
85 - SHEATHE_ONE_HAND =
86 - SHEATHE_TWO_HAND =
87 - SHEATHE_DUAL_WIELD =
88 - SHEATHE_OFF_HAND =
89 - SHEATHE_BOW =
90 - SHEATHE_RANGED_WEAPON =
91 - SHEATHE_POLEARM =
92 - UNSHEATHE_ONE_HAND =
93 - UNSHEATHE_TWO_HAND =
94 - UNSHEATHE_DUAL_WIELD =
95 - UNSHEATHE_OFF_HAND =
96 - UNSHEATHE_BOW =
97 - UNSHEATHE_RANGED_WEAPON =
98 - UNSHEATHE_POLEARM =
99 - DEATH_DEFAULT =
100 - DEATH_SWIM =
101 - LOOT =
102 - SHORT_INTERACT =
103 - LOOP_INTERACT =
104 - PUSH =
105 - PULL =
106 - CLIMB =
107 - SWIM_UP =
108 - SWIM_DOWN =
109 - IDLE_FLY =
110 - FLY_F =
111 - FLY_B =
112 - FLY_L =
113 - FLY_R =
114 - FLY_FL =
115 - FLY_FR =
116 - FLY_BL =
117 - FLY_BR =
118 - FLY_UP =
119 - FLY_DOWN =
120
Constants ​
StringDEFAULT_TREE_PATH ="res://addons/chroniclenode/runtime_classes/entity/components/rig/animation_m...- ConstantsfloatMOVEMENT_BLEND_DURATION =0.5- How many seconds a movement animation takes to blend into the next.floatBLEND_FADE_IN_TIME =0.5- How many seconds an action animation takes to fade in.floatBLEND_FADE_OUT_TIME =0.5- How many seconds an action animation takes to fade out.StringMOVING_STATE_MACHINE ="MovingStateMachine"- Animation Tree Node NamesStringMOVING_STATE_TIME_SCALE ="MovingStateTimeScale"- The name of the speed parameter of the moving state in the animation tree.StringTURNING_BLEND ="TurningBlend"- The name of the blend parameter of the turn in the animation tree.StringTURN_BLEND_SPACE ="TurnBlendSpace"- The name of the blend space of the turn in the animation tree.StringFULL_BODY_CASTING ="FullBodyCasting"- The name of the full body casting node in the animation tree.StringFULL_BODY_ACTION ="FullBodyAction"- The name of the full body action node in the animation tree.StringFULL_BODY_ONE_SHOT ="FullBodyOneshot"- The name of the full body one shot node in the animation tree.StringFULL_BODY_TIME_SCALE ="FullBodyTimeScale"- The name of the full body speed parameter in the animation tree.StringFULL_BODY_BLEND ="FullBodyBlend"- The name of the full body blend parameter in the animation tree.StringUPPER_BODY_CASTING ="UpperBodyCasting"- The name of the upper body casting node in the animation tree.StringUPPER_BODY_ACTION ="UpperBodyAction"- The name of the upper body action node in the animation tree.StringUPPER_BODY_ONE_SHOT ="UpperBodyOneshot"- The name of the upper body one shot node in the animation tree.StringUPPER_BODY_TIME_SCALE ="UpperBodyTimeScale"- The name of the upper body speed parameter in the animation tree.StringUPPER_BODY_BLEND ="UpperBodyBlend"- The name of the upper body blend parameter in the animation tree.StringSTANDING_LOCOMOTION ="StandingLocomotion"- The name of the standing locomotion blend space in the animation tree.StringSWIMMING_LOCOMOTION ="SwimmingLocomotion"- The name of the swimming locomotion blend space in the animation tree.StringCROUCHING_LOCOMOTION ="CrouchingLocomotion"- The name of the crouching locomotion blend space in the animation tree.StringDEATH_ANIMATION ="DeathAnimation"- The name of the death animation node in the animation tree.StringDEATH_BLEND ="DeathBlend"- The name of the death blend parameter in the animation tree.StringJUMP ="Jump"- Movement State Machine StatesStringFALL_START ="FallStart"- The name of the fall start node in the animation tree.StringFALL_LOOP ="FallLoop"- The name of the fall loop node in the animation tree.StringLAND_SOFT ="LandSoft"- The name of the soft landing node in the animation tree.StringLAND_MEDIUM ="LandMedium"- The name of the medium landing node in the animation tree.StringLAND_HARD ="LandHard"- The name of the hard landing node in the animation tree.floatVERTICAL_BLEND =2.0- How far up and down the swimming blend space reaches: the swim up and swim down animations sit at (0, VERTICAL_BLEND) and (0, -VERTICAL_BLEND), beyond the ring of the swim animations, so swimming or flying up and sideways blends the two and the usual positions (inside the ring) are not changed.StringDEFAULT_UNARMED_STANCE ="combat_idle"- Default stance animation when unarmedArray[float]TURN_POSITIONS =[-1.0, -0.5, 0.0, 0.5, 1.0]- Turn blend space layout, by blend POSITION (not point index - the order of points inside the tree resource is not guaranteed, and it did not match the order assumed here before): -1.0 = turn 180 left, -0.5 = turn 90 left, 0.0 = idle (center), 0.5 = turn 90 right, 1.0 = turn 180 right
Variable descriptions ​
bool animations_blocked = false ​
State Management
bool animations_death_blocked = false ​
True once the entity died: no animation but the death one plays.
String current_stance_tag = "" # Animation name from WeaponClassDefinition.stance_tag ​
The stance of the weapon in hand (the stance tag of its weapon class), which picks the animations.
bool current_combat_mode = false ​
True while the entity is in its combat stance.
Dictionary fallback_chains ​
Smart fallback mapping for missing animations
ChronoManager chrono_manager ​
ChronoManager ref
Method descriptions ​
void setup_animations( system_hub: GameHost.SystemHub, entity_data: EntityDefinition ) ​
Builds the player for an entity: reads the animation map of its definition.
void setup_animation_tree( tree_resource_path: String = DEFAULT_TREE_PATH ) ​
Sets up the animation tree from a tree resource (the default one if none is given). Needs setup_animations first.
void set_free_movement_look( air: bool, pose: String = "" ) ​
What the entity does in a free movement mode: air plays the flying animations (they fall back to the swimming ones), pose is the name of one animation that plays instead of all of them (empty = none). The claim on the movement of the entity says it (see MovementClaim).
void set_free_vertical_motion( fraction: float ) ​
How fast the entity moves up (1) or down (-1) in a free movement mode, as a share of its vertical speed. The swimming blend moves towards the swim up or swim down animation with it.
void play_movement( movement_data: MovementData ) ​
Plays the movement animation for the movement data (direction, speed, stance).
void play_turning_animation( turn_direction: float, is_crouched: bool = false, is_swimming: bool = false ) ​
Plays a turn in place, to the left or right (a negative direction is left).
void set_turn_direction( turn_direction: float ) ​
Updates only the turn direction of a turn that is already playing. Does not touch the clips, the loop setup or the fade, so it is safe to call while turning.
void stop_turning_animation() ​
Stops the turn animation.
void play_casting_animation( ability_selection: AnimationSelectionAbility, weapon_type: String = "" ) ​
Plays the casting animation of an ability (for the weapon type in hand).
void play_ability_animation( ability_selection: AnimationSelectionAbility, weapon_type: String = "" ) ​
Plays the animation of an ability (for the weapon type in hand).
void stop_casting_animation() ​
Ends the casting animation.
void stop_ability_animation() ​
Ends the ability animation.
void cancel_casting_animation() ​
Cuts the casting animation short (the cast was interrupted).
void stop_upper_body_animation() ​
Stops what the upper body plays.
void play_social_animation( social_selection: AnimationSelectionSocial, context: String = "" ) ​
Play a social animation using AnimationSelectionSocial
void play_jump_animation() ​
Plays the jump.
void play_falling_animation() ​
Plays the fall.
void play_land_animation( impact_level: int ) ​
Plays the landing, softer or harder by the impact level.
void play_combat_animation( animation_type: String, weapon_type: String = "" ) ​
Plays a combat animation by its type (attack, hit, dodge ...) for the weapon type in hand.
bool play_trigger_animation( slots: PackedStringArray, weapon_tag: String = "" ) ​
Plays the animation of a trigger (a dodge, a parry ...): the clip of its slot in the animation map for the weapon in hand, or of the next slot of slots (the ones it falls back to). False when the creature has none
bool play_status_effect_start_animation( status_name: String, speed: float = 1.0 ) ​
Play status effect start animation using AnimationTree
bool play_status_effect_loop_animation( status_name: String, speed: float = 1.0 ) ​
Play status effect loop animation (continuous until effect ends)
bool play_status_effect_end_animation( status_name: String, speed: float = 1.0 ) ​
Play status effect end animation
void stop_status_effect_animation() ​
Stop status effect animations and return to normal state
bool has_status_effect_animation( status_name: String, phase: String ) ​
Check if a status effect animation phase exists
float get_status_effect_animation_duration( status_name: String, phase: String ) ​
Get the duration of a status effect animation phase
void play_block_animation( weapon_type: String = "" ) ​
Simple wrapper functions for backwards compatibility Plays a block. weapon_type is the animation tag of the weapon in hand: when it is a Weapon Profile with block clips, one of them is played; otherwise the block of the animation map for the weapon type
bool play_profile_clip( weapon_tag: String, role: String ) ​
Plays one of the clips (picked at random) of a role of a Weapon Profile as a combat one-shot. False when the tag is not a profile or the role has no clip this creature has
void play_dodge_animation( weapon_type: String = "" ) ​
Plays the dodge. weapon_type is the animation tag of the weapon in hand: a Weapon Profile with dodge clips plays one of them; with none (or no weapon given) the dodge of the animation map plays
void play_hit_animation( weapon_type: String = "" ) ​
Plays the animation of being hit. weapon_type as for the dodge: the profile's hit clips first, else the hit of the animation map
void play_equipment_animation( action: String, weapon_type: String ) ​
For sheathe/unsheathe (simpler since they're single animations, not arrays) weapon_type is the animation tag of the weapon: a Weapon Profile with sheathe or unsheathe clips plays one of them, otherwise the fixed lists of the animation map for the weapon type
void play_sheathe_animation( weapon_type: String ) ​
Plays putting the weapon away.
void play_unsheathe_animation( weapon_type: String ) ​
Plays drawing the weapon.
void play_death_animation() ​
Plays the death animation and blocks the others.
void reset_from_death() ​
Lets the animations play again after a resurrection.
void set_stance_tag( stance_tag: String ) ​
Set the combat stance animation tag from WeaponClassDefinition.stance_tag Called by Entity when equipment changes
void enter_combat_mode() ​
Switches the idle and movement animations to the combat ones.
void exit_combat_mode() ​
Switches back to the normal idle and movement animations.
void play_interaction_animation( interaction_type: String ) ​
Plays the animation of an interaction (open, use, pick up ...).
void cleanup_timers() ​
Stops the tweens and timers of the player.
bool is_animation_almost_complete() ​
Is the animation playing now almost at its end?