fix "want to look at player" for when player rides a vehicle
This commit is contained in:
parent
c9e38c7b29
commit
e9afeefb7d
17
src/actor.rs
17
src/actor.rs
|
@ -566,13 +566,26 @@ fn handle_wants_lookat(
|
|||
&mut ExternalTorque,
|
||||
&WantsToLookAt,
|
||||
)>,
|
||||
q_playercam: Query<&Position, With<PlayerCamera>>,
|
||||
id2pos: Res<game::Id2Pos>,
|
||||
) {
|
||||
let player_pos = if let Ok(player_pos) = q_playercam.get_single() {
|
||||
player_pos
|
||||
} else {
|
||||
error!("Can't find player position");
|
||||
return;
|
||||
};
|
||||
|
||||
for (pos, mut rot, mut _torque, target_id) in &mut query {
|
||||
if let Some(target_pos) = id2pos.0.get(&target_id.0) {
|
||||
let target_pos = if target_id.0 == cmd::ID_SPECIAL_PLAYERCAM {
|
||||
player_pos
|
||||
} else if let Some(target_pos) = id2pos.0.get(&target_id.0) {
|
||||
target_pos
|
||||
} else {
|
||||
continue;
|
||||
};
|
||||
rot.0 = look_at_quat(**pos, *target_pos, DVec3::Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_damage(
|
||||
|
|
|
@ -18,6 +18,7 @@ use bevy_xpbd_3d::prelude::*;
|
|||
use regex::Regex;
|
||||
use std::time::SystemTime;
|
||||
|
||||
pub const ID_SPECIAL_PLAYERCAM: &str = "PLAYERCAMERA";
|
||||
pub const ID_EARTH: &str = "earth";
|
||||
pub const ID_SOL: &str = "sol";
|
||||
pub const ID_JUPITER: &str = "jupiter";
|
||||
|
|
|
@ -462,7 +462,7 @@ actor -3300 10 0 pizzeria
|
|||
angularmomentum 0 0 0
|
||||
wants maxrotation 0
|
||||
wants maxvelocity 0
|
||||
wants lookat player
|
||||
wants lookat PLAYERCAMERA
|
||||
thrust 15 6 3 400 0.5
|
||||
rotationy -126
|
||||
scale 3
|
||||
|
@ -479,7 +479,7 @@ actor -3300 10 0 pizzeria
|
|||
thrust 1.2 1 1 20 1.5
|
||||
wants maxrotation 0
|
||||
wants maxvelocity 0
|
||||
wants lookat player
|
||||
wants lookat PLAYERCAMERA
|
||||
rotationy -90
|
||||
angularmomentum 0 0 0
|
||||
pronoun he
|
||||
|
@ -538,7 +538,7 @@ actor 100 -18000 2000 clippy
|
|||
angularmomentum 0 0 0
|
||||
wants maxrotation 0
|
||||
wants maxvelocity 0
|
||||
wants lookat player
|
||||
wants lookat PLAYERCAMERA
|
||||
thrust 15 6 3 400 0.5
|
||||
pointofinterest yes
|
||||
rotationy -90
|
||||
|
@ -690,7 +690,7 @@ actor -184971e3 149410e3 -134273e3 clippy
|
|||
angularmomentum 0 0 0
|
||||
wants maxrotation 0
|
||||
wants maxvelocity 0
|
||||
wants lookat player
|
||||
wants lookat PLAYERCAMERA
|
||||
thrust 15 6 3 400 0.5
|
||||
pointofinterest yes
|
||||
rotationy -90
|
||||
|
@ -835,7 +835,7 @@ actor 0 -44e3 0 clippy
|
|||
angularmomentum 0 0 0
|
||||
wants maxrotation 0
|
||||
wants maxvelocity 0
|
||||
wants lookat player
|
||||
wants lookat PLAYERCAMERA
|
||||
thrust 15 6 3 400 0.5
|
||||
pointofinterest yes
|
||||
rotationy -90
|
||||
|
|
Loading…
Reference in a new issue