The problem begins with the names of the properties.
When we’re talking about a collision (involving two colliders) and there’s a property named
collider and another named
otherCollider, it isn’t reasonable to expect
otherCollider to refer to anything else but the other guy (and not ourselves). In the current implementation of
otherCollider refers to ourselves and
collider refers to the other guy. That’s not only unintuitive, but confusing and contrary to what semantics or common sense would dictate.
The problem is further exacerbated by how the documentation describes
collider as the “incoming” collider (like it matters who’s “coming”, or moving, or whatever - it doesn’t) and
otherCollider as the “other” collider involved. It not only doesn’t help, but exacerbates the problem with further usage of “other” with inverted semantics in the description of the property.
thisCollider) should be the one that refers to ourselves (the collider attached to the GameObject running the script), and
otherCollider, which is the worst offender, should be the one that refers to the other guy (the collider we collided with), and not the other way around, which is how it’s currently implemented.
The current implementation, besides very confusing, is detrimental to code clarity and logic and to the learning process.
I spent a whole day trying to figure out “why my game is inverting the properties” before realizing that’s actually how they’re implemented.