Setting OnTriggerEnter to a second object collider

I like to keep these simplified instead of trying to explain everything that I’m doing, so here’s the watered down version:

  • I have an object, called Object A
  • I have another object, called Object B
  • In its script, I tell Object A to do something if a bool is true
  • This bool only equals true if the player moves into the triggered collider of Object B

However, I don’t really know how to do this. I was going to use OnTriggerEnter but with (ObjectB Collider other) instead of just (Collider other), though that doesn’t seem to work. I’m working in C#. Anyone have any ideas?

Hello

Sory I didn’t understand the last part of the question. Can you please check the following link that whether is this you want?

You have access to both objects in OnTriggerEnter just check the name

void OnTriggerEnter (Collider other) {

     // Verify the collider is ObjectB by checking name
     if (other.name == "Whatever Object B is named") {

          // set your bool or whatever you want to do
          yourBoolName = true; 
    }
}

Assuming you want set the bool false on exit you use OnTriggerExit.

void OnTriggerExit (Collider other) {

     // Verify the collider is ObjectB by checking name
     if (other.name == "Whatever Object B is named") {

          // Clear your bool or whatever you want to do
          yourBoolName = false; 
    }
}