0

I have a problem. I created a game with coins that the player collects. I a code that when the player collisions with the coin the coin will be destroyed. When he on the same Y all the game is good. However, when the player fall on a coin he get stuck on the coin for a second and after the coin is destroyd. and it is not happen immediately. I want that when the player collisions the coin from fall it will be destroyed immediately.

This is the code:

if(collision.collider.tag.Equals("coin"))
        {
            Destroy(collision.gameObject);
        }
DanielM
  • 1
  • 1

1 Answers1

1

You could use a trigger instead. That way you would not impact the coin and trade physics.

    void OnTriggerEnter2D(collider2D collision){}
 
quomitter
  • 34
  • 2