fix player rotation
This commit is contained in:
@@ -1,4 +1,8 @@
|
|||||||
use crate::{GameState, control::ControllerSet};
|
use crate::{
|
||||||
|
GameState,
|
||||||
|
control::{ControllerSet, Inputs},
|
||||||
|
player::{LocalPlayer, Player, PlayerBodyMesh},
|
||||||
|
};
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_replicon::client::ClientSystems;
|
use bevy_replicon::client::ClientSystems;
|
||||||
|
|
||||||
@@ -22,4 +26,22 @@ pub fn plugin(app: &mut App) {
|
|||||||
.before(ClientSystems::Receive)
|
.before(ClientSystems::Receive)
|
||||||
.run_if(in_state(GameState::Playing)),
|
.run_if(in_state(GameState::Playing)),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
app.add_systems(
|
||||||
|
FixedUpdate,
|
||||||
|
rotate_others.run_if(in_state(GameState::Playing)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn rotate_others(
|
||||||
|
players: Query<(&Inputs, &Children), (With<Player>, Without<LocalPlayer>)>,
|
||||||
|
mut rig: Query<(&mut Transform, &PlayerBodyMesh)>,
|
||||||
|
) {
|
||||||
|
for (input, children) in players.iter() {
|
||||||
|
for child in children.iter() {
|
||||||
|
if let Ok((mut rig, _)) = rig.get_mut(child) {
|
||||||
|
*rig = rig.looking_to(input.look_dir, Vec3::Y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ pub fn plugin(app: &mut App) {
|
|||||||
.replicate_once::<PlayerBodyMesh>()
|
.replicate_once::<PlayerBodyMesh>()
|
||||||
.replicate_once::<Npc>()
|
.replicate_once::<Npc>()
|
||||||
.replicate::<SquishAnimation>()
|
.replicate::<SquishAnimation>()
|
||||||
.replicate::<Transform>()
|
.replicate_once::<Transform>()
|
||||||
.replicate_once::<SpawnTrail>()
|
.replicate_once::<SpawnTrail>()
|
||||||
.replicate_as::<Visibility, SerVisibility>();
|
.replicate_as::<Visibility, SerVisibility>();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user