Connect 2 gameobjects to interact with them simultaneously?

Hi,

I have 2 separate gameobjects which I want want to highlight at the same time when the cursor is hovering over just one of them. Is there a way to connect them/their colliders within Unity?

Thanks in advance!

Here is if you want to link just two objects together:

public GameObject connectedObject;  

Then add the other GameObject in the inspector. This is for if you want 3 or more, same process just add the relevant GameObjects in the inspector:

public class LinkedGameObjects : MonoBehaviour
{
public List<GameObject> gameObjectList = new List<GameObject>();

     OnColliderEnter()
     {
     foreach(GameObject g in gameObjectList)
          {
          // Put whatever your logic is here. I assume g.material = new Material(). //
          }

     }
}

You might also want to look at delegates and events, but this wouldn’t be the best solution in every situation. This would really only be an option if you didn’t want to just arbitrarily connect objects together that may or may not have anything in common. Likewise, it would decouple any references and would be the better way to handle this if the game objects were to be spawned into the scene. Mythirdalias is right on the money, this is just another way to go about doing it.