Implementing head collision detection using OnCollisionEnter2D()

I tried modify C# code and found another way to implement head collision detection using OnCollisionEnter2D(), and It worked.


I’m not sure if it’s a conventional method to locate the collider that has collided on the current game object.

1 Like

I’m totally new to C# but I really wanted to do this! I was scratching my head for a good long while, trying various things to try and understand how the different things were talking to each other.

I’m really pleased to say I was super close with this, I just wasn’t aware of the ‘otherCollider’ part of other.otherCollider! I was trying to access things like other.PolygonCollider2D, but it wasn’t liking it.

1 Like

I was also wondering how to use Collider instead of Trigger, since you can’t seem to differentiate sub colliders (or any sub-components inside an object) with a tag. Thank you Hertz_Zheng!

1 Like

Privacy & Terms