Correct center calculation for visibility colliders.

This commit is contained in:
Nolan Darilek 2022-02-01 17:14:15 -06:00
parent 184cfac47e
commit 288b1605b9

View File

@ -313,17 +313,18 @@ fn spawn_colliders(
"Top left: {:?}\ntop right: {:?}\nbottom left: {:?}\nbottom right: {:?}",
top_left, top_right, bl, br
);*/
let center = (bl.0 as f32 + half_width, br.1 as f32 + half_height);
let x = center.0;
let y = center.1;
let center = (
bl.0 as f32 + half_width + 0.5,
br.1 as f32 + half_height + 0.5,
);
/*println!(
"Create shape at {:?} of width {} and height {}",
"Create shape at {:?} of width {:?} and height {:?}",
center, width, height
);*/
let id = commands
.spawn_bundle(ColliderBundle {
shape: ColliderShape::cuboid(half_width, half_height).into(),
position: Vec2::new(x, y).into(),
position: Vec2::new(center.x(), center.y()).into(),
..Default::default()
})
.insert(MapObstruction)