Sometimes, Unity can be fairly confusing. 
Iâm telling you how to figure out what we can access via code. This will hopefully help you with similar problems in the future.
The error message states that the Collision2D class does not contain any definition for CompareTag(). If you double click the error message, the line with collision.CompareTag will get highlighted in your code.
To figure out what we are able to access, we usually take a look at the Unity API.
In this case, we look for Collision2D. Given the docs are correct, there is no CompareTag() method but there are other things we could access via collision.{member} where {member} is just a placeholder, not real code.
Letâs ignore the code for a moment. What do we want to achieve? We want to know if the other game object has got the âWorldCollisionâ tag.
With this in mind, letâs take another look at the API. In the list, we can see many things we could access. We skim the description and click whatever sounds promising. This is more or less guessing around. (Sometimes, there is no premade solution, so our search might end in an impasse. In this case, there is a solution, though.)
If you want to challenge yourself, please stop reading, and check the API yourself.
How I looked for the relevant information, and found it âŚ
Iâm checking gameObject first, and get to this page. Then I click the type GameObject. I can see that the GameObject class (and therefore the object) contains a CompareTag() method. Perfect.
Now, I know what I need. I just have to follow the âpathâ: Collision2D object â gameObject â CompareTag().
In your case, the variable of type Collision2D is named collision, so we write collision.gameObject.CompareTag.
In your code, you would write if (collision.gameObject.CompareTag("WorldCollision")).
That will hopefully work. If not, I made a mistake somewhere.
As a side note, Collision2D and Collider2D are fairly inconsistent. I have no clue why one class contains CompareTag() while the other doesnât. Both classes are written by humans, though. Some classes were created decades ago. For this reason, I wouldnât worry too much about it. Instead, I would briefly check the API to hopefully get a solution. Everything else is just a waste of time. ^^