[Noob] Collision Trigger in Player or Coin ?

Hi,

I’m starting with unity and i have some questions.

Is it better to check for collision in Player or in prefabs Coin ? (The player can catch coins.)

Player :

    void OnTriggerEnter2D(Collider2D obj)
    {
        switch (obj.tag) {
        case "Coin":
            Destroy(obj.gameObject);
            Global.score++;
            break;
        }
    }

Coin :

void OnTriggerEnter2D()
    {
            Destroy(gameObject);
            Global.score++;
    }

And in the seconde case it increases score by 2. I guess because it takes both player and Coin but is there a mean to trigger this script only once when collision ?
(Edit : Ok for this one, I thaught that unthicking a script would desactivate it :slight_smile: )

Is it bad for performance to let empty functions like : update{ } ?

Is there a mean to show errors in MonoDevelop ?

Why when a block is quite fast, it can pass through other rigid blocks ?

Thanks !
Have a nice day !

Because physics updates happen in steps rather than continuously like in real life.

1 Like

Yes, you can use Physics2D.changeStopsCallbacks to control this.

Use Rigidbody2D.collisionDetectionMode set to continuous for fast moving objects. This is more expensive but guarantees that objects won’t pass through each other.

1 Like

Thanks for your replies, any idea for the other questions ? :slight_smile:

The first question
and
“Is it bad for performance to let empty functions like : update{ } ?”