How can I create a system which allows me to detect when these two entities collide (when the player touches the coin?), I currently have a system which looks like the following but it is not working.
fn despawn_coin_on_contact(
mut commands: Commands,
players: Query<&CollidingEntities, With<Player>>,
coins: Query<(), With<Coin>>,
) {
for colliding_entities in &players {
for entity in colliding_entities.iter() {
if coins.contains(entity) {
commands.entity(entity).despawn_recursive();
}
}
}
}
I have two components in my game a coin and a player, the player looks roughly like the following...
and the coin looks like this,
How can I create a system which allows me to detect when these two entities collide (when the player touches the coin?), I currently have a system which looks like the following but it is not working.