When using the following:
void OnCollisionEnter2D(Collision2D newCollision) {
//method stuff here
}
Is it possible to declare a variable of type Collision2D outside of the function, then call it within the function? I only ask as i’ve tried it and I get error CS1041: Identifier expected, but I’m trying to determine if its just me missing something out or if its just not legal C# formatting.
So basically, instead of the above, have…
public Collision2D newCollision;
void OnCollisionEnter2D(newCollision) {
//method stuff here
}