Finding Objects in Trigger and Setting Modifiers

I’m having a hard time with this. I have an object, it can be surrounded by 1 to 4 other objects. Depending on what those objects variables are set to, I’m have modifiers I want to put on the damage applied to the object. I can’t figure out how to first of all, find out what objects are in the trigger, and then two, how to effect my modifiers based on what’s in there.

Currently I have this, just to detect what is in the trigger. It doesn’t seem to work. If it matters, the game does start with the objects already in the trigger. Is that a problem? I thought this code below would print the objects to the console so I could verify it’s working, but it doesn’t.

 // Other Characters
     public List<GameObject> others; 
void OnTriggerEnter(Collider other)
     {
         if (other.tag == "character")
         {
             others.Add(other.gameObject);
             Debug.Log(other.gameObject);
         }
     }

You’re trying to add ‘other’ into your List as a GameObject, when it is a Collider. :slight_smile:

1 Like

other.gameobject would work fine for this I think.

Edit: woops misread and I have my second coffee now hang on, other.gameobject.tag? That way you’re getting the tagged gameobject rather than the collider.