From 39c3e45a04aa363eb2c6d442e08d36606fc07d0e Mon Sep 17 00:00:00 2001 From: Zicklag Date: Sat, 6 Aug 2022 19:47:37 -0500 Subject: [PATCH] Re-add Attack Y Position Correction For now this is the easiest way to maintain consistency. --- src/fighter_state.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/fighter_state.rs b/src/fighter_state.rs index 7d9a78e9..db85fba6 100644 --- a/src/fighter_state.rs +++ b/src/fighter_state.rs @@ -237,6 +237,8 @@ impl Grabbing { #[derive(Component, Reflect, Default, Debug)] #[component(storage = "SparseSet")] pub struct Attacking { + /// The initial y-height of the figther when starting the attack + pub start_y: f32, pub has_started: bool, pub is_finished: bool, } @@ -469,6 +471,7 @@ fn attacking( mut fighters: Query<( Entity, &mut Animation, + &mut Transform, &mut LinearVelocity, &Facing, &Stats, @@ -482,6 +485,7 @@ fn attacking( for ( entity, mut animation, + mut transform, mut velocity, facing, stats, @@ -501,6 +505,7 @@ fn attacking( // Start the attack if !attacking.has_started { attacking.has_started = true; + attacking.start_y = transform.translation.y; // Start the attack from the beginning animation.play(Attacking::ANIMATION, false); @@ -571,8 +576,13 @@ fn attacking( } } - // If the animation is done if animation.is_finished() { + // Stop moving + **velocity = Vec2::ZERO; + + // Make sure we "land on the ground" ( i.e. the player y position hasn't changed ) + transform.translation.y = attacking.start_y; + // Set flopping to finished attacking.is_finished = true; }