Fix footstep sounds when jumping
This commit is contained in:
parent
9756572ccf
commit
4512734395
@ -46,4 +46,11 @@ impl PlayerEffects {
|
||||
}
|
||||
self.walk_sfx_cd_remaining = self.walk_sfx_cd;
|
||||
}
|
||||
|
||||
pub fn jump(&mut self) {
|
||||
if let Some(walk) = &mut self.walk_sound {
|
||||
walk.play();
|
||||
}
|
||||
self.walk_sfx_cd_remaining = 0.;
|
||||
}
|
||||
}
|
||||
|
||||
@ -275,6 +275,9 @@ impl IPlayer for LocalPlayer {
|
||||
|
||||
fn jump(&mut self) {
|
||||
if self.try_jump() {
|
||||
if let Some(effects) = &mut self.effects {
|
||||
effects.bind_mut().jump();
|
||||
}
|
||||
if let Some(peer) = &mut NetworkManager::singleton().bind_mut().peer {
|
||||
match peer {
|
||||
PeerKind::Client(peer, addr) => peer.send_reliable(&addr, Jump(0)),
|
||||
@ -542,7 +545,7 @@ impl ICharacterBody3D for LocalPlayer {
|
||||
scoreboard.set_visible(Input::singleton().is_action_pressed("scoreboard"));
|
||||
}
|
||||
|
||||
if self.movement_dir.length_squared() > 0. {
|
||||
if self.movement_dir.length_squared() > 0. && self.base().is_on_floor() {
|
||||
if let Some(effects) = &mut self.effects {
|
||||
effects.bind_mut().walk();
|
||||
}
|
||||
@ -844,7 +847,11 @@ impl IPlayer for RemotePlayer {
|
||||
}
|
||||
|
||||
fn jump(&mut self) {
|
||||
self.try_jump();
|
||||
if self.try_jump() {
|
||||
if let Some(effects) = &mut self.effects {
|
||||
effects.bind_mut().jump();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn get_look_up(&self) -> f32 {
|
||||
@ -995,6 +1002,7 @@ impl ICharacterBody3D for RemotePlayer {
|
||||
}
|
||||
|
||||
if self.movement_dir.length_squared() > 0.
|
||||
&& self.base().is_on_floor()
|
||||
&& let Some(effects) = &mut self.effects
|
||||
{
|
||||
effects.bind_mut().walk();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user