Correct center calculation for visibility colliders.
This commit is contained in:
parent
184cfac47e
commit
288b1605b9
11
src/map.rs
11
src/map.rs
|
@ -313,17 +313,18 @@ fn spawn_colliders(
|
||||||
"Top left: {:?}\ntop right: {:?}\nbottom left: {:?}\nbottom right: {:?}",
|
"Top left: {:?}\ntop right: {:?}\nbottom left: {:?}\nbottom right: {:?}",
|
||||||
top_left, top_right, bl, br
|
top_left, top_right, bl, br
|
||||||
);*/
|
);*/
|
||||||
let center = (bl.0 as f32 + half_width, br.1 as f32 + half_height);
|
let center = (
|
||||||
let x = center.0;
|
bl.0 as f32 + half_width + 0.5,
|
||||||
let y = center.1;
|
br.1 as f32 + half_height + 0.5,
|
||||||
|
);
|
||||||
/*println!(
|
/*println!(
|
||||||
"Create shape at {:?} of width {} and height {}",
|
"Create shape at {:?} of width {:?} and height {:?}",
|
||||||
center, width, height
|
center, width, height
|
||||||
);*/
|
);*/
|
||||||
let id = commands
|
let id = commands
|
||||||
.spawn_bundle(ColliderBundle {
|
.spawn_bundle(ColliderBundle {
|
||||||
shape: ColliderShape::cuboid(half_width, half_height).into(),
|
shape: ColliderShape::cuboid(half_width, half_height).into(),
|
||||||
position: Vec2::new(x, y).into(),
|
position: Vec2::new(center.x(), center.y()).into(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
.insert(MapObstruction)
|
.insert(MapObstruction)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user