I basically ripped the collision function straight out of the breakout example, and even if I remove everything except the "ball" sprite, it spams the collision event.
fn check_bounce(mut commands: Commands,
mut ball_query: Query<(&mut Velocity, &Transform)>,
collider_query: Query<(Entity, &Transform)>,
mut collision_events: EventWriter<CollisionEvent>,
){
let (mut ball_velocity, ball_transform) = ball_query.single_mut();
let ball_size = ball_transform.scale.truncate();
for (collider_entity, transform, ) in &collider_query {
let collision = collide(
ball_transform.translation,
ball_size,
transform.translation,
transform.scale.truncate(),
);
if let Some(collision) = collision {
println!("Collision detected.");
// Sends a collision event so that other systems can react to the collision
collision_events.send_default();
}
}
}
Anyone experienced this before?