fix new camera control system to work with vehicles
This commit is contained in:
parent
3f656924e1
commit
e15cf6791f
|
@ -51,7 +51,7 @@ fn setup_camera(
|
||||||
pub fn sync_camera_to_player(
|
pub fn sync_camera_to_player(
|
||||||
settings: Res<settings::Settings>,
|
settings: Res<settings::Settings>,
|
||||||
mut q_camera: Query<&mut Transform, With<Camera>>,
|
mut q_camera: Query<&mut Transform, With<Camera>>,
|
||||||
q_playercam: Query<(&actor::Actor, &Transform), (With<actor::PlayerCamera>, Without<actor::PlayerDrivesThis>, Without<Camera>)>,
|
q_playercam: Query<(&actor::Actor, &Transform), (With<actor::PlayerCamera>, Without<Camera>)>,
|
||||||
) {
|
) {
|
||||||
if q_camera.is_empty() || q_playercam.is_empty() {
|
if q_camera.is_empty() || q_playercam.is_empty() {
|
||||||
return;
|
return;
|
||||||
|
@ -119,13 +119,12 @@ fn apply_input_to_player(
|
||||||
thruster_sound_controller: Query<&AudioSink, With<audio::ComponentThrusterSound>>,
|
thruster_sound_controller: Query<&AudioSink, With<audio::ComponentThrusterSound>>,
|
||||||
rocket_sound_controller: Query<&AudioSink, With<audio::ComponentRocketSound>>,
|
rocket_sound_controller: Query<&AudioSink, With<audio::ComponentRocketSound>>,
|
||||||
ion_sound_controller: Query<&AudioSink, With<audio::ComponentIonSound>>,
|
ion_sound_controller: Query<&AudioSink, With<audio::ComponentIonSound>>,
|
||||||
mut q_engine: Query<&mut actor::Engine, With<actor::PlayerDrivesThis>>,
|
|
||||||
mut q_playercam: Query<(
|
mut q_playercam: Query<(
|
||||||
&mut Transform,
|
&mut Transform,
|
||||||
&mut actor::Engine,
|
&mut actor::Engine,
|
||||||
&mut AngularVelocity,
|
&mut AngularVelocity,
|
||||||
&mut LinearVelocity,
|
&mut LinearVelocity,
|
||||||
), (With<actor::PlayerCamera>, Without<actor::PlayerDrivesThis>, Without<Camera>)>,
|
), (With<actor::PlayerCamera>, Without<Camera>)>,
|
||||||
) {
|
) {
|
||||||
let dt = time.delta_seconds();
|
let dt = time.delta_seconds();
|
||||||
let mut play_thruster_sound = false;
|
let mut play_thruster_sound = false;
|
||||||
|
@ -136,7 +135,7 @@ fn apply_input_to_player(
|
||||||
focused = window_result.unwrap().focused;
|
focused = window_result.unwrap().focused;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok((mut player_transform, player_engine, mut angularvelocity, mut v)) = q_playercam.get_single_mut() {
|
if let Ok((mut player_transform, mut engine, mut angularvelocity, mut v)) = q_playercam.get_single_mut() {
|
||||||
|
|
||||||
if angularvelocity.length_squared() > 0.0001 {
|
if angularvelocity.length_squared() > 0.0001 {
|
||||||
angularvelocity.x *= 0.98;
|
angularvelocity.x *= 0.98;
|
||||||
|
@ -182,8 +181,6 @@ fn apply_input_to_player(
|
||||||
// total diagonal acceleration is faster than the forward acceleration alone.
|
// total diagonal acceleration is faster than the forward acceleration alone.
|
||||||
axis_input = axis_input.clamp(Vec3::splat(-1.0), Vec3::splat(1.0));
|
axis_input = axis_input.clamp(Vec3::splat(-1.0), Vec3::splat(1.0));
|
||||||
|
|
||||||
let mut engine = if let Ok(engine) = q_engine.get_single_mut() { engine } else { player_engine };
|
|
||||||
|
|
||||||
// Apply movement update
|
// Apply movement update
|
||||||
let forward_factor = engine.current_warmup * (if axis_input.z < 0.0 {
|
let forward_factor = engine.current_warmup * (if axis_input.z < 0.0 {
|
||||||
engine.thrust_forward
|
engine.thrust_forward
|
||||||
|
|
Loading…
Reference in a new issue