Crosshair drawing over statues without going invisible past -1000 on the Y axis
This commit is contained in:
parent
aaddc46c65
commit
d24bf8defc
4 changed files with 21 additions and 17 deletions
|
@ -3,6 +3,13 @@ use bevy::render::camera::Camera;
|
|||
|
||||
pub fn startup(mut commands: Commands) {
|
||||
let mut bundle = (Camera2dBundle::default(), IsDefaultUiCamera);
|
||||
bundle.0.projection = OrthographicProjection {
|
||||
near: f32::MIN,
|
||||
far: f32::MAX,
|
||||
scale: 1.,
|
||||
..default()
|
||||
};
|
||||
// bundle.0.transform.translation.z = f32::MAX;
|
||||
bundle.0.projection.scale = 1.;
|
||||
commands.spawn(bundle);
|
||||
}
|
||||
|
|
|
@ -96,6 +96,7 @@ fn main() -> AppExit {
|
|||
(update,).after(input::process_input),
|
||||
(
|
||||
player::control,
|
||||
player::player_debug_info,
|
||||
statue::spawn_statue,
|
||||
movement::update_velocity_by_heading,
|
||||
movement::resolve_velocity.after(movement::update_velocity_by_heading),
|
||||
|
|
|
@ -9,6 +9,9 @@ pub struct Heading(pub Vec2);
|
|||
#[derive(Component, Deref, DerefMut, Debug, Default)]
|
||||
pub struct Speed(pub f32);
|
||||
|
||||
#[derive(Component, Deref, DerefMut, Debug, Default)]
|
||||
pub struct Height(pub f32);
|
||||
|
||||
#[derive(Component, Debug, Default)]
|
||||
pub struct YSortable;
|
||||
|
||||
|
@ -24,9 +27,9 @@ pub fn update_velocity_by_heading(mut query: Query<(&mut Velocity, &Speed, &Head
|
|||
}
|
||||
}
|
||||
|
||||
pub fn ysort(mut q: Query<&mut Transform, With<YSortable>>) {
|
||||
pub fn ysort(mut q: Query<(&mut Transform, Option<&Height>), With<YSortable>>) {
|
||||
q.iter_mut()
|
||||
.for_each(|mut tf| tf.translation.z = -tf.translation.y)
|
||||
.for_each(|(mut tf, z)| tf.translation.z = -tf.translation.y - z.map(|z| z.0).unwrap_or(0.))
|
||||
}
|
||||
|
||||
#[derive(Bundle, Debug, Default)]
|
||||
|
|
|
@ -55,28 +55,15 @@ pub fn startup(
|
|||
.with_children(|player| {
|
||||
let mesh = meshes.add(Capsule2d::new(3.0, 25.0));
|
||||
let material = materials.add(Color::hsl(360. * 1 as f32 / 3 as f32, 0.95, 0.7));
|
||||
// let global_transform = GlobalTransform::from_xyz(
|
||||
// 0.0, 20.0,
|
||||
// // TODO: need some way to ensure this draws above everything else?
|
||||
// // a UI layer or something?
|
||||
// 1000.,
|
||||
// );
|
||||
|
||||
let transform = Transform::from_xyz(
|
||||
0.0, 0.0,
|
||||
// TODO: need some way to ensure this draws above everything else?
|
||||
// a UI layer or something?
|
||||
1000.,
|
||||
);
|
||||
let transform = Transform::from_xyz(0.0, 0.0, 500.);
|
||||
|
||||
player.spawn((
|
||||
Crosshair,
|
||||
// TODO: crosshair transform?
|
||||
MaterialMesh2dBundle {
|
||||
// global_transform,
|
||||
mesh: mesh.into(),
|
||||
material,
|
||||
transform,
|
||||
material,
|
||||
..default()
|
||||
},
|
||||
));
|
||||
|
@ -102,6 +89,12 @@ pub fn control(input: Res<Input>, mut player: Query<&mut Heading, With<Player>>)
|
|||
}
|
||||
}
|
||||
|
||||
pub fn player_debug_info(mut player: Query<(&Heading, &Transform), With<Player>>) {
|
||||
if let Ok((heading, transform)) = player.get_single_mut() {
|
||||
info!("{heading:#?} {transform:#?}");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn exit(mut commands: Commands, q: Query<Entity, With<Player>>) {
|
||||
for id in q.iter() {
|
||||
commands.entity(id).despawn_recursive();
|
||||
|
|
Loading…
Reference in a new issue