Flagging the Player to 'Ignore Collisions' on Certain Rigidbodies

I have run into a small problem:

In my game world, enemies spawn Coins. Coins are rigidbodies, flying into the air, spinning about, and coming to rest on the ground. They use a SphereCollider to control collision.

My player object uses a CharacterController.

I can’t figure out how to have the player ignore the rigidbody collisions of these Coins, or vice versa. In essence, I’d like the SphereCollider to act like a Trigger when the player collides with it, completely ignore enemy collisions, but act like a standard rigidbody in all other circumstances.

I’m really stumped on this one. I assume there’s a relatively simple solution as it seems to be the kind of thing that people might want often in their games… I just can’t find it!

Thanks for any help offered :slight_smile:

Have you tried modifying the Layer Collision Matrix under Edit → Project Settings → Physics ?

No, I haven’t! I knew I’d missed something obvious! Thankyou!

EDIT: That solved the problem, but introduced a new one. Now the player passes through the coins, but doesn’t issue any kind of OnTrigger event or anything that I can use to collect the coins.

Ideally, I’d be able to have rigidbody coins collide with rigidbody ground, but not the CharacterController player, or other rigibodies (that bit works). But also, the player should be able to issue some kind of OnTrigger event on the coins so that they can be collected.

Is there any way to define “Act like a rigidbody in these circumstances, but act like a trigger in these other circumstances”?

I solved the problem, more or less. Not sure it’s the best solution, but it works:

Parent a second game object under the first. The first controls all world collisions, and the second is a trigger only, for player collisions.