is it possible to not get triggered by your own BoxCollider ?

I have a problem, i have 2 car (the red one is my player) they both have a boxCollider attache to their gameObject and i want to stop the car who enter the boxCollider of the other one (because the red is faster than the grey). Here is an exemple schema:

I want my red car to stop when it enters the Collider box of the grey car but not my grey car to stop. I would also like the grey car to stop when it enters the Collider box of my red car ( player).

The problem is when the red car enters the boxcollider of the grey car both stops because the boxCollider also triggers the grey car and not only the red one. I would therefore like the trigger of the boxCollider not to trigger the GameObject with which it is associated. Is that possible? Or is there an oder solution

Here is the code of the red car(player):

    void OnTriggerExit(Collider other)
    {
        if (other.tag == "TrafficCar")
        {
            targetSpeed = 14f;
        }

    }
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "TrafficCar")
        {
            targetSpeed = 0f;
        }

    }

the grey car have the same code, only the tag change. Any help would be aprecieted !

Have a reference to your own collider and check if it’s it.

public Collider ownCollider;

private void OnTriggerEnter(Collider other)
     {
         if (other.tag == "TrafficCar" && other != ownCollider)
         {
             targetSpeed = 0f;
         }
 
     }

Edit: or if the collider is in the same game object as the script you can check that (which was the question): other.gameObject != gameObject

In the if statement you can check to see if the velocity of the car is greater than the one that you are colliding with. private void OnTriggerEnter(Collider other){ if (other.tag == "TrafficCar" && this.getComponent().Velocity > other.gameobject.getComponent().Velocity){ targetSpeed = 0f; } }

Easiest way I can think of to handle this, without a ton of velocity checks, etc… would be to modify your OnTriggerEnter function to see if the colliding object is in front of or behind your transform position, and only run your slow down code is the colliding object is in front of your position.

This way, using your image as an example, Grey car detects trigger, sees collision is occurring behind it, discards collision(does nothing) Red car detects trigger, sees collision is occurring in front of it, slows down.

Hope this helps,
-Larry