Animation sync (#60)
This commit is contained in:
@@ -2,9 +2,9 @@ use super::{ControlState, ControllerSet};
|
||||
use crate::{
|
||||
GameState,
|
||||
animation::AnimationFlags,
|
||||
character::HasCharacterAnimations,
|
||||
control::{controller_common::MovementSpeedFactor, controls::ControllerSettings},
|
||||
player::PlayerBodyMesh,
|
||||
utils::commands::IsServer,
|
||||
};
|
||||
use bevy::prelude::*;
|
||||
use happy_feet::prelude::{Grounding, KinematicVelocity, MoveInput};
|
||||
@@ -42,21 +42,19 @@ fn apply_controls(
|
||||
&mut MoveInput,
|
||||
&mut Grounding,
|
||||
&mut KinematicVelocity,
|
||||
&mut AnimationFlags,
|
||||
&ControllerSettings,
|
||||
&MovementSpeedFactor,
|
||||
&HasCharacterAnimations,
|
||||
)>,
|
||||
rig_transform_q: Option<Single<&GlobalTransform, With<PlayerBodyMesh>>>,
|
||||
mut anim_flags: Query<&mut AnimationFlags>,
|
||||
is_server: Option<Res<IsServer>>,
|
||||
) {
|
||||
let Ok((mut move_input, mut grounding, mut velocity, settings, move_factor, has_anims)) =
|
||||
let Ok((mut move_input, mut grounding, mut velocity, mut flags, settings, move_factor)) =
|
||||
character.single_mut()
|
||||
else {
|
||||
return;
|
||||
};
|
||||
|
||||
let mut flags = anim_flags.get_mut(*has_anims.collection()).unwrap();
|
||||
|
||||
let mut direction = -controls.move_dir.extend(0.0).xzy();
|
||||
|
||||
if let Some(ref rig_transform) = rig_transform_q {
|
||||
@@ -72,8 +70,10 @@ fn apply_controls(
|
||||
move_input.set(direction * move_factor.0);
|
||||
|
||||
if controls.jump && grounding.is_grounded() {
|
||||
flags.jumping = true;
|
||||
flags.just_jumped = true;
|
||||
if is_server.is_some() {
|
||||
flags.jumping = true;
|
||||
flags.jump_count += 1;
|
||||
}
|
||||
happy_feet::movement::jump(settings.jump_force, &mut velocity, &mut grounding, Dir3::Y)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user