Make dashback more lenient

This commit is contained in:
2026-08-29 11:36:13 +02:00
parent dc8e4e93a5
commit 07834dcb08
10 changed files with 159 additions and 59 deletions
+26 -6
View File
@@ -3,7 +3,11 @@ use std::time::Duration;
use bevy::prelude::*;
use crate::{
fighter::{FighterECB, FighterFacingDirection, FighterTranslation, FighterVisual, visual::FighterAnimations}, player::Player,
fighter::{
FighterECB, FighterFacingDirection, FighterTranslation, FighterVisual,
visual::FighterAnimations,
},
player::Player,
};
#[derive(Component)]
@@ -26,7 +30,11 @@ pub struct FighterAnimationFrame {
impl FighterAnimationFrame {
pub const fn new(kind: AnimKind, repeat: bool) -> Self {
Self { kind, frame: 0, repeat }
Self {
kind,
frame: 0,
repeat,
}
}
pub fn reset(&mut self, kind: AnimKind, repeat: bool) {
@@ -78,16 +86,28 @@ pub fn setup_fighter_animation_player(
}
}
pub fn apply_animation(children: Query<(&mut Transform, &FighterFacingDirection, &FighterAnimationFrame), With<FighterVisual>>) {
pub fn apply_animation(
children: Query<
(
&mut Transform,
&FighterFacingDirection,
&FighterAnimationFrame,
),
With<FighterVisual>,
>,
) {
for (mut trf, facing_direction, frame) in children {
// Melee model scale is in decimeters
trf.rotation = Quat::IDENTITY;
if let AnimKind::Turn = frame.kind {
trf.rotate_local_y(std::f32::consts::PI * -0.5 * facing_direction.to_sign().to_num::<f32>());
trf.rotate_local_y(
std::f32::consts::PI * -0.5 * facing_direction.to_sign().to_num::<f32>(),
);
} else {
trf.rotate_local_y(std::f32::consts::PI * 0.5 * facing_direction.to_sign().to_num::<f32>());
trf.rotate_local_y(
std::f32::consts::PI * 0.5 * facing_direction.to_sign().to_num::<f32>(),
);
}
}
}
+1 -1
View File
@@ -40,7 +40,7 @@ pub struct FighterAttributes {
pub air_dodge_duration: u32,
pub air_dodge_velocity: FGi32,
pub air_dodge_decay: FGi32
pub air_dodge_decay: FGi32,
}
impl FighterAttributes {
+13 -9
View File
@@ -10,7 +10,10 @@ use crate::fighter::ecb::FighterPreviousECB;
use crate::fighter::manifest::{FighterManifest, FighterManifestRegistry};
use crate::fighter::state::StateNameDebug;
use crate::fighter::visual::FighterAnimations;
use crate::fighter::{Fighter, FighterECB, FighterFacingDirection, FighterPreviousTranslation, FighterTranslation, FighterVelocity};
use crate::fighter::{
Fighter, FighterECB, FighterFacingDirection, FighterPreviousTranslation, FighterTranslation,
FighterVelocity,
};
use crate::input::FighterInput;
use crate::match_loading::MatchPlayer;
@@ -45,26 +48,27 @@ pub fn fighter_debug(
ui.label(format!("{:?}", vel));
ui.label(format!("{:?}", input.get_last_frame()));
});
}
Ok(())
}
pub fn animation_debug(
query: Query<(
&GlobalTransform,
&FighterAnimationFrame,
&FighterAnimations,
)>,
query: Query<(&GlobalTransform, &FighterAnimationFrame, &FighterAnimations)>,
baked_anims: Res<Assets<BakedFighterAnimations>>,
mut gizmos: Gizmos,
) {
for (global_transform, frame, anims) in query {
let baked: &BakedFighterAnimations = baked_anims.get(&anims.baked).expect("Baked anims should be in");
let baked: &BakedFighterAnimations = baked_anims
.get(&anims.baked)
.expect("Baked anims should be in");
for bone in &baked.bone_names {
let out = anims.sample_bone(&baked_anims, *frame, bone);
if let Some(out) = out {
let pos = global_transform.transform_point(Vec3::new(out.cols[3][0].to_num(), out.cols[3][1].to_num(), out.cols[3][2].to_num()));
let pos = global_transform.transform_point(Vec3::new(
out.cols[3][0].to_num(),
out.cols[3][1].to_num(),
out.cols[3][2].to_num(),
));
gizmos.cross(pos, 0.5, bevy::color::palettes::css::RED);
}
}
+30 -6
View File
@@ -36,10 +36,22 @@ pub fn snapshot_fighter_ecb(fighters: Query<(&FighterECB, &mut FighterPreviousEC
impl FighterECB {
pub fn to_3d_lineloop(&self, trf: Transform) -> [Vec3; 4] {
let rel_up = trf.transform_point(Vec3::new(0.0, (self.vertical_half + self.vertical_half).to_num(), 0.0));
let rel_up = trf.transform_point(Vec3::new(
0.0,
(self.vertical_half + self.vertical_half).to_num(),
0.0,
));
let rel_down = trf.transform_point(Vec3::new(0.0, 0.0, 0.0));
let rel_left = trf.transform_point(Vec3::new((-self.horizontal_half).to_num(), self.vertical_half.to_num(), 0.0));
let rel_right = trf.transform_point(Vec3::new(self.horizontal_half.to_num(), self.vertical_half.to_num(), 0.0));
let rel_left = trf.transform_point(Vec3::new(
(-self.horizontal_half).to_num(),
self.vertical_half.to_num(),
0.0,
));
let rel_right = trf.transform_point(Vec3::new(
self.horizontal_half.to_num(),
self.vertical_half.to_num(),
0.0,
));
[rel_up, rel_right, rel_down, rel_left]
}
@@ -50,10 +62,22 @@ impl FighterECB {
impl FighterPreviousECB {
pub fn to_3d_lineloop(&self, trf: Transform) -> [Vec3; 4] {
let rel_up = trf.transform_point(Vec3::new(0.0, (self.vertical_half + self.vertical_half).to_num(), 0.0));
let rel_up = trf.transform_point(Vec3::new(
0.0,
(self.vertical_half + self.vertical_half).to_num(),
0.0,
));
let rel_down = trf.transform_point(Vec3::new(0.0, 0.0, 0.0));
let rel_left = trf.transform_point(Vec3::new((-self.horizontal_half).to_num(), self.vertical_half.to_num(), 0.0));
let rel_right = trf.transform_point(Vec3::new(self.horizontal_half.to_num(), self.vertical_half.to_num(), 0.0));
let rel_left = trf.transform_point(Vec3::new(
(-self.horizontal_half).to_num(),
self.vertical_half.to_num(),
0.0,
));
let rel_right = trf.transform_point(Vec3::new(
self.horizontal_half.to_num(),
self.vertical_half.to_num(),
0.0,
));
[rel_up, rel_right, rel_down, rel_left]
}
+14 -5
View File
@@ -7,8 +7,8 @@ use bevy_ggrs::prelude::*;
use serde::{Deserialize, Serialize};
pub mod animation;
pub mod baked_animation;
pub mod attributes;
pub mod baked_animation;
pub mod collision;
pub mod debug;
pub mod ecb;
@@ -28,8 +28,16 @@ pub use motion::{FighterPreviousTranslation, FighterTranslation, FighterVelocity
use crate::{
fighter::{
animation::animation_init, manifest::FighterManifest, state::{FighterState, fall::FallState}, visual::FighterAnimations,
}, input::FighterInput, math::{int::FGi32, vec::FGVec2}, player::Player, schedule::GameplaySet, stage::line::StageCollision,
animation::animation_init,
manifest::FighterManifest,
state::{FighterState, fall::FallState},
visual::FighterAnimations,
},
input::FighterInput,
math::{int::FGi32, vec::FGVec2},
player::Player,
schedule::GameplaySet,
stage::line::StageCollision,
};
use state::state_interrupt_system;
@@ -91,7 +99,7 @@ pub struct FighterVisual;
#[derive(Component)]
pub struct Fighter {
id: FighterId,
pub manifest: Handle<FighterManifest>
pub manifest: Handle<FighterManifest>,
}
impl Plugin for FighterPlugin {
@@ -174,7 +182,7 @@ pub fn spawn_fighter(
},
Fighter {
id: manifest.1.id,
manifest: manifest.0
manifest: manifest.0,
},
FighterFacingDirection::Right,
FighterECB {
@@ -189,5 +197,6 @@ pub fn spawn_fighter(
animation::FighterAnimationFrame::new(animation::AnimKind::Wait, true),
FighterVisual,
FighterInput::default(),
crate::camera::FighterCameraExtents::default(),
));
}
+6 -2
View File
@@ -4,7 +4,7 @@ use crate::fighter::collision;
use crate::fighter::state::fall::FallState;
use crate::fighter::state::ground::{self, GroundedMotionResult, GroundedStateCommon};
use crate::fighter::state::land::LandingState;
use crate::fighter::state::{FighterState, air, dash, jump, wait, walk};
use crate::fighter::state::{air, dash, jump, wait, walk, FighterState};
#[derive(Debug, Clone, Hash)]
pub struct TurnState {
@@ -80,9 +80,13 @@ pub fn check_input(
grounded_common: &GroundedStateCommon,
) -> Option<FighterState> {
let input_frame = state_context.input.get_last_frame();
let smash_input_frame_threshold = state_context
.game_settings
.input_common
.smash_input_frame_threshold;
if !input_frame.movement.x.is_zero()
&& input_frame.movement.x.signum() != state_context.facing_direction.to_sign()
&& state_context.input.get_frames_in_smash_move_deadzone() > smash_input_frame_threshold
{
return Some(FighterState::Turn(TurnState {
grounded_common: grounded_common.clone(),
+6 -8
View File
@@ -18,20 +18,18 @@ pub struct WaitState {
impl FighterStateImpl for WaitState {
const NAME: &'static str = "Wait";
fn check_interrupt(&self, state_context: &mut FighterStateContext) -> Option<FighterState> {
if let Some(state) = ground::grounded_movement_standstill_common_interrupts(
if let Some(state) = ground::grounded_movement_common_interrupts(state_context, &self.grounded_common) {
Some(state)
} else if let Some(state) = ground::grounded_movement_standstill_common_interrupts(
state_context,
&self.grounded_common,
) {
// Prevent transitioning into myself
&self.grounded_common)
{
// Don't transition into yourself
if let FighterState::Wait(_) = state {
None
} else {
Some(state)
}
} else if let Some(state) =
ground::grounded_movement_common_interrupts(state_context, &self.grounded_common)
{
Some(state)
} else {
None
}
+5 -1
View File
@@ -6,6 +6,7 @@ use super::{FighterStateContext, FighterStateImpl, dash, ground, wait};
use crate::fighter::animation::AnimKind;
use crate::fighter::state::FighterState;
use crate::fighter::state::fall::FallState;
use crate::fighter::state::turn;
use crate::fighter::state::ground::{GroundedMotionResult, GroundedStateCommon};
#[derive(Debug, Clone, Hash)]
@@ -16,7 +17,10 @@ pub struct WalkState {
impl FighterStateImpl for WalkState {
const NAME: &'static str = "Walk";
fn check_interrupt(&self, state_context: &mut FighterStateContext) -> Option<FighterState> {
if let Some(state) =
if let Some(state) = turn::check_input(state_context, &self.grounded_common) {
return Some(state)
}
else if let Some(state) =
ground::grounded_movement_common_interrupts(state_context, &self.grounded_common)
{
return Some(state);