Skip to content

Commit

Permalink
Re-add Attack Y Position Correction
Browse files Browse the repository at this point in the history
For now this is the easiest way to maintain consistency.
  • Loading branch information
zicklag committed Aug 7, 2022
1 parent 927f2cb commit 39c3e45
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/fighter_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -469,6 +471,7 @@ fn attacking(
mut fighters: Query<(
Entity,
&mut Animation,
&mut Transform,
&mut LinearVelocity,
&Facing,
&Stats,
Expand All @@ -482,6 +485,7 @@ fn attacking(
for (
entity,
mut animation,
mut transform,
mut velocity,
facing,
stats,
Expand All @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 39c3e45

Please sign in to comment.