Detecting if my object is NOT Colliding with anything?

Please use code tags when you post code on the forum. Code is very hard to read in the browser.

You don’t have to define what is the other object you were collided before the OnCollisionExit2D. The incoming parameter is for you to know which collision ended. You can collide with more than one thing at the same time.

For example:

  • you’re colliding with an enemy → you are decreasing the player’s health while it is colliding
  • you’re colliding with a trigger area where you can flip a switch or something

When you go out of the collision with the switch, you don’t want to end to hurt the player, since he’s still colliding with the enemy. So this way you can check, which collision has ended.