Create area AABBs of the correct size.
This commit is contained in:
parent
02eff61016
commit
74e66dbd59
|
@ -339,7 +339,9 @@ fn spawn_colliders(
|
||||||
for room in &map.rooms {
|
for room in &map.rooms {
|
||||||
let shape =
|
let shape =
|
||||||
ColliderShape::cuboid((room.width() / 2) as f32, (room.height() / 2) as f32);
|
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
|
let id = commands
|
||||||
.spawn_bundle(ColliderBundle {
|
.spawn_bundle(ColliderBundle {
|
||||||
collider_type: ColliderType::Sensor,
|
collider_type: ColliderType::Sensor,
|
||||||
|
@ -348,7 +350,7 @@ fn spawn_colliders(
|
||||||
position,
|
position,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
.insert(shape.compute_aabb(&position))
|
.insert(aabb)
|
||||||
.insert(Area)
|
.insert(Area)
|
||||||
.id();
|
.id();
|
||||||
commands.entity(map_entity).push_children(&[id]);
|
commands.entity(map_entity).push_children(&[id]);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user