map camera: don't jump around when deselecting target
This commit is contained in:
parent
9de72a0cfc
commit
1e9f6aa057
|
@ -310,6 +310,13 @@ pub fn update_map_camera(
|
||||||
} else {
|
} else {
|
||||||
(player_entity, player_trans)
|
(player_entity, player_trans)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Don't jump around when deselecting.
|
||||||
|
if mapcam.center_on_entity != Some(target_entity) && q_target.is_empty() {
|
||||||
|
mapcam.offset_x = -player_trans.translation.x as f64;
|
||||||
|
mapcam.offset_z = -player_trans.translation.z as f64;
|
||||||
|
}
|
||||||
|
|
||||||
mapcam.center_on_entity = Some(target_entity);
|
mapcam.center_on_entity = Some(target_entity);
|
||||||
|
|
||||||
// Update map grid
|
// Update map grid
|
||||||
|
@ -375,6 +382,8 @@ pub fn update_map_camera(
|
||||||
mapcam.target_zoom_level *= target_trans.scale.x as f64 * factor;
|
mapcam.target_zoom_level *= target_trans.scale.x as f64 * factor;
|
||||||
mapcam.zoom_level *= target_trans.scale.x as f64 * factor;
|
mapcam.zoom_level *= target_trans.scale.x as f64 * factor;
|
||||||
mapcam.initialized = true;
|
mapcam.initialized = true;
|
||||||
|
mapcam.offset_x = 0.0;
|
||||||
|
mapcam.offset_z = 0.0;
|
||||||
}
|
}
|
||||||
let mut change_zoom: f64 = 0.0;
|
let mut change_zoom: f64 = 0.0;
|
||||||
if keyboard_input.pressed(settings.key_map_zoom_out) {
|
if keyboard_input.pressed(settings.key_map_zoom_out) {
|
||||||
|
|
Loading…
Reference in a new issue