OnCollisionEnter2D(Collision2D collision) vs. (Collision2D other)

Hi,

When I type into Visual Studio

private void OnCollisionEnter2D(

Visual Studio then automatically fills out the rest of the method as:

private void OnCollisionEnter2D(Collision2D collision)

This is different to the tutorial in which it seems t autocomplete as:

private void OnCollisionEnter2D(Collision2D other)

I am curious as to why my VS might autocomplete this differently to the tutorial, and what the difference between collision and other is here?

Any help greatly appreciated, thanks :slight_smile:

Hi,

Welcome to our community! :slight_smile:

There is a template somewhere, and it might be that the template is different for VS and VS Code. However, these differences do not affect the functionality.

In your example, you could either manually rename the method parameter in your code, or you could use the parameter as it is. other and collision are just parameter/variable names. They work like your own variables, and you may rename them if you want.

Did this help?


See also:

Hi, thanks so much for the response, that makes sense :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms