Create area AABBs of the correct size.

This commit is contained in:
Nolan Darilek 2021-09-16 14:25:17 -05:00
parent 02eff61016
commit 74e66dbd59

View File

@ -339,7 +339,9 @@ fn spawn_colliders(
for room in &map.rooms {
let shape =
ColliderShape::cuboid((room.width() / 2) as f32, (room.height() / 2) as f32);
let position = Vec2::new(room.center().x() + 0.5, room.center().y() + 0.5).into();
let position: ColliderPosition =
point!(room.center().x(), room.center().y()).into();
let aabb = shape.compute_aabb(&position);
let id = commands
.spawn_bundle(ColliderBundle {
collider_type: ColliderType::Sensor,
@ -348,7 +350,7 @@ fn spawn_colliders(
position,
..Default::default()
})
.insert(shape.compute_aabb(&position))
.insert(aabb)
.insert(Area)
.id();
commands.entity(map_entity).push_children(&[id]);