change camera movement
parent
6b2075c2a4
commit
9a0c360172
|
@ -6,7 +6,6 @@ pub struct Camera;
|
||||||
pub fn camera_follow_player(
|
pub fn camera_follow_player(
|
||||||
player: Query<(&Transform, &Player), Without<Camera>>,
|
player: Query<(&Transform, &Player), Without<Camera>>,
|
||||||
mut camera: Query<(&mut Transform, &Camera), Without<Player>>,
|
mut camera: Query<(&mut Transform, &Camera), Without<Player>>,
|
||||||
time: Res<Time>,
|
|
||||||
) {
|
) {
|
||||||
let player_pos = if let Some(player) = player.iter().next() {
|
let player_pos = if let Some(player) = player.iter().next() {
|
||||||
player.0.translation
|
player.0.translation
|
||||||
|
@ -14,21 +13,8 @@ pub fn camera_follow_player(
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let ds = time.delta_seconds() * 5.0;
|
|
||||||
// TODO Change this to normal movement
|
|
||||||
for (mut trans, _) in camera.iter_mut() {
|
for (mut trans, _) in camera.iter_mut() {
|
||||||
|
trans.translation = player_pos + Vec3::new(-50.0, 100.0, 50.0);
|
||||||
trans.look_at(player_pos, Vec3::Y);
|
trans.look_at(player_pos, Vec3::Y);
|
||||||
|
|
||||||
// keep a distance to the player
|
|
||||||
if trans.translation.distance(player_pos) > 170.0 {
|
|
||||||
let mut d = trans.rotation * Vec3::Z * ds;
|
|
||||||
d.y = 0.0;
|
|
||||||
trans.translation -= d;
|
|
||||||
}
|
|
||||||
if trans.translation.distance(player_pos) < 130.0 {
|
|
||||||
let mut d = trans.rotation * Vec3::Z * ds;
|
|
||||||
d.y = 0.0;
|
|
||||||
trans.translation += d;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,9 +97,6 @@ fn setup(
|
||||||
|
|
||||||
// camera
|
// camera
|
||||||
commands
|
commands
|
||||||
.spawn_bundle(PerspectiveCameraBundle {
|
.spawn_bundle(PerspectiveCameraBundle::default())
|
||||||
transform: Transform::from_xyz(-40.0, 110.0, 40.0).looking_at(Vec3::ZERO, Vec3::Y),
|
|
||||||
..Default::default()
|
|
||||||
})
|
|
||||||
.insert(Camera);
|
.insert(Camera);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue