From 81736a4fab66424038024d13ac0e10ee94bdcae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=80lex=20Rom=C3=A0n?= Date: Thu, 27 Aug 2026 20:35:12 +0200 Subject: [PATCH] Add fall animation --- assets/fighters/test/test.fighter.ron | 1 + src/fighter/animation.rs | 1 + src/fighter/state/fall.rs | 17 +++++++++++++---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/assets/fighters/test/test.fighter.ron b/assets/fighters/test/test.fighter.ron index 5b805e5..9590256 100644 --- a/assets/fighters/test/test.fighter.ron +++ b/assets/fighters/test/test.fighter.ron @@ -43,5 +43,6 @@ Landing: "PlyPurin5K_Share_ACTION_Landing", AirDodge: "PlyPurin5K_Share_ACTION_EscapeAir", DoubleJump: "PlyPurin5K_Share_ACTION_JumpAerialF1", + Fall: "PlyPurin5K_Share_ACTION_Fall" } ) diff --git a/src/fighter/animation.rs b/src/fighter/animation.rs index 8ed35c8..8d2794f 100644 --- a/src/fighter/animation.rs +++ b/src/fighter/animation.rs @@ -91,4 +91,5 @@ pub enum AnimKind { DoubleJump, Landing, AirDodge, + Fall, } diff --git a/src/fighter/state/fall.rs b/src/fighter/state/fall.rs index 97e7582..65f4535 100644 --- a/src/fighter/state/fall.rs +++ b/src/fighter/state/fall.rs @@ -1,9 +1,9 @@ - use super::{FighterStateContext, FighterStateImpl}; +use crate::fighter::animation::AnimKind; +use crate::fighter::collision; use crate::fighter::state::ground::GroundedStateCommon; use crate::fighter::state::land::LandingState; use crate::fighter::state::{FighterState, air, jump}; -use crate::fighter::collision; #[derive(Debug, Clone, Copy, Hash)] pub struct FallState; @@ -14,7 +14,13 @@ impl FighterStateImpl for FallState { jump::check_input_double_jump(state_context) } - fn on_enter(&mut self, _state_context: &mut super::FighterStateContext) {} + fn on_enter(&mut self, state_context: &mut super::FighterStateContext) { + state_context.animation_transitions.play( + &mut state_context.animation_player, + state_context.animations.clips[&AnimKind::Fall], + std::time::Duration::ZERO, + ).repeat(); + } fn update(&mut self, state_context: &mut super::FighterStateContext) { air::integrate_gravity(state_context.velocity, state_context.fighter_attribs); @@ -40,7 +46,10 @@ impl FighterStateImpl for FallState { let grounded_common = GroundedStateCommon { current_line_id: res.line_id, }; - Some(FighterState::Land(LandingState { grounded_common, duration_counter: 0 })) + Some(FighterState::Land(LandingState { + grounded_common, + duration_counter: 0, + })) } else { None }