The coin detects two colliders

I have a player which is a parent to an object called isGrounded and I have a coin which I wanted it to detect the collision of the player, and it was set to isTrigger.
When I tested it it showed that two coins where colected.
And it is because it is detecting the collider of isGrounded too.
Although I haven’t written any code for the isGrounded to detect it.

Anybody knows how to solve it?

You can discern what collider(s) you hit by using Layers.

You can also do it by listing the collider you care about and comparing.

If the callback script is on the coin, you could also set a collected flag prior to incrementing the coin count.

1 Like