How to check if 2 collisions are on the same objects ? (is player on the same ground than enemy?)

Hi guys,
I’d like to check if my groundCheck for player and groundCheck for enemy are colliding with the same ground.

My detection system is an OverlapCircle checking for a Ground layer.

So I want to look at my “collision” events for both detections and compare the objects concerned.

NB : all that is 2D
Thanks !

Simply compare the objects found in the “ground checks”.

For example if you do the ground check using raycast you probably do RaycastHit2D hit = Physics2D.Raycast(transform.position, -Vector2.up); or something like that. If you compare the hit.transform of your 2 resulting RaycastHit2D then you’ll know if they are the same object or not.

You might try putting a bool CollidingWithPlayer into the ground tile, and then when a collision occurs check to see if its the player, if it is set to true. then, if another collision occurs while that property is true, you can compare the new collision, dismiss if its just the player colliding again, and if not, then presto.