Multiple colliders on an object that can be triggered.

I have a ground check collider and a collider that represents the players attack range on the same object. How can I use both of them in one OnTriggerStay2D void?

for example like:

...

public Collider2D colliderName;
public Collider2D anotherCollider;

void OnTriggerStay2D(Collider2D colliderName)
{
      if (colliderName.CompareTag("Example")
               //do smth
}

now how do make another function for anotherCollider?

thanks

This might help.

And fyi. Since you have both a field variable called colliderName AND a parameter named colliderName in the OnTriggerStay2D, I believe the code in the IF statement you have will be using the parameter’s variable instead of the field variable.

Several ways to fix issue, if you intend to use the field variable:
this.colliderName to use the field variable OR just change the var names. Example: make the parameter’s name be just ‘collider’. That way its not difficult to know when you are using the field or parameter variable.