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 !