Currently im using the Position of two objects (comets and the ship) to detect if they collide.
fn collision_detection(
comets: Query<&Transform, With<Comet>>,
mut ships: Query<(&Transform, &mut ShipStatus), With<Ship>>,
) {
for comet in comets.iter() {
for (ship, mut status) in ships.iter_mut() {
if comet.translation.x < ship.translation.x + 80.0 && comet.translation.y < ship.translation.y + 80.0
&& comet.translation.x > ship.translation.x - 80.0 && comet.translation.y > ship.translation.y - 80.0 {
status.dead = true;
}
}
}
}
But there has to be a better way of doing this.
system
that gets a simple iterator over the ships and comets... – Somatoplasm