I'm new to unity so please excuse dumbness
When I try to start the game, I get the error message: "The name "collision" does not exist in the current context" which makes no sense as it's an in build function (I think, I have no idea) Here's my the code:
private void OnCollisionEnter2D(Collision2D other) {
if (collision.gameObject.tag == "Ground")
grounded = true;
}
The error refers to the "collision.gameObject.tag"
CodePudding user response:
Your name collision should match the name given in the line above within the parentheses, in your case "other". So you can change either the word collision to other, or you can change the word other to collision. They just need to be the same thing.
Collision2D other is a function variable. You can use the variable in your function by using its name.