Bevy 0.17 Migration Final PR (#76)
* Get bevy 0.17 compiling and running (#72) * get bevy 0.17 compiling and running * try to fix CI breaking from const assertion for client/server features * fix `bin` -> `lib` for `shared` in CI * typo * fix some collider issues (#73) * Physics/controller improvements (#74) * trying to fix physics prediction * fixed prediction desync * substantial controller improvements * Finish off main bevy 0.17 migration (#75) * fix lookdir issues - airplane moving backwards - player model facing backwards - camera was technically backwards the whole time, and player models were facing the right way; camera is now facing forwards - firing without a target now respects lookdir * fix aim targeting * migrate to bevy_trenchbroom 0.10 crates release * fixed colliders not being adjusted out of worldspace * predict platforms to stop constant rollbacks while riding them * fix key/head drop visuals not working * Fix key/head drop random initial force * fixed static head drops duplicating * fix platform velocity inheritance * fix thrown projectiles not autorotating * fix inconsistent explosion animations * update avian3d to 0.4.1 * fix controller snapping to fixed angle upon switching heads * clean up commented code * fix broken physics positions * Clean comments, fix warnings (#77) * clean comments, fix warnings * fix missing import * steamworks 162 libs * fix mouselook --------- Co-authored-by: extrawurst <mail@rusticorn.com>
This commit is contained in:
@@ -3,8 +3,9 @@ use crate::{
|
||||
GameState,
|
||||
animation::AnimationFlags,
|
||||
control::{ControllerSettings, controller_common::MovementSpeedFactor},
|
||||
player::PlayerBodyMesh,
|
||||
};
|
||||
#[cfg(feature = "client")]
|
||||
use crate::{control::LookDirMovement, player::PlayerBodyMesh};
|
||||
use bevy::prelude::*;
|
||||
use happy_feet::prelude::{Grounding, KinematicVelocity, MoveInput};
|
||||
use lightyear::prelude::input::native::ActionState;
|
||||
@@ -15,7 +16,11 @@ impl Plugin for CharacterControllerPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(
|
||||
FixedUpdate,
|
||||
(rotate_view, apply_controls)
|
||||
(
|
||||
#[cfg(feature = "client")]
|
||||
rotate_view,
|
||||
apply_controls,
|
||||
)
|
||||
.chain()
|
||||
.in_set(ControllerSet::ApplyControlsRun)
|
||||
.run_if(in_state(GameState::Playing)),
|
||||
@@ -23,8 +28,10 @@ impl Plugin for CharacterControllerPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "client")]
|
||||
fn rotate_view(
|
||||
actions: Query<&ActionState<ControlState>>,
|
||||
look_dir: Res<LookDirMovement>,
|
||||
mut player: Query<(&mut Transform, &ChildOf), With<PlayerBodyMesh>>,
|
||||
) {
|
||||
for (mut tr, child_of) in player.iter_mut() {
|
||||
@@ -34,12 +41,12 @@ fn rotate_view(
|
||||
continue;
|
||||
}
|
||||
|
||||
tr.rotate_y(controls.look_dir.x * -0.001);
|
||||
tr.rotate_y(look_dir.0.x * -0.001);
|
||||
}
|
||||
}
|
||||
|
||||
fn apply_controls(
|
||||
mut character: Query<(
|
||||
character: Single<(
|
||||
&mut MoveInput,
|
||||
&mut Grounding,
|
||||
&mut KinematicVelocity,
|
||||
@@ -48,29 +55,15 @@ fn apply_controls(
|
||||
&MovementSpeedFactor,
|
||||
&ActionState<ControlState>,
|
||||
)>,
|
||||
rig_transform_q: Option<Single<&GlobalTransform, With<PlayerBodyMesh>>>,
|
||||
) {
|
||||
let Ok((
|
||||
mut move_input,
|
||||
mut grounding,
|
||||
mut velocity,
|
||||
mut flags,
|
||||
settings,
|
||||
move_factor,
|
||||
controls,
|
||||
)) = character.single_mut()
|
||||
else {
|
||||
return;
|
||||
};
|
||||
|
||||
let mut direction = -controls.move_dir.extend(0.0).xzy();
|
||||
|
||||
if let Some(ref rig_transform) = rig_transform_q {
|
||||
direction = (rig_transform.forward() * direction.z) + (rig_transform.right() * direction.x);
|
||||
}
|
||||
let (mut move_input, mut grounding, mut velocity, mut flags, settings, move_factor, controls) =
|
||||
character.into_inner();
|
||||
|
||||
let ground_normal = *grounding.normal().unwrap_or(Dir3::Y);
|
||||
|
||||
let mut direction = controls.move_dir.extend(0.0).xzy();
|
||||
let look_dir_right = controls.look_dir.cross(Vec3::Y);
|
||||
direction = (controls.look_dir * direction.z) + (look_dir_right * direction.x);
|
||||
let y_projection = direction.project_onto(ground_normal);
|
||||
direction -= y_projection;
|
||||
direction = direction.normalize_or_zero();
|
||||
|
||||
Reference in New Issue
Block a user