Best way to get a script variable

Okay so currently I understand that using GameObject.GetComponent<>(); is a very costly call, but is there any way to simplify this? In my context 2 units coming into proximity contact via a trigger, they would both have to go into each others unit script to retrieve what team they are on, so am I going about this the right way, and if so is getcomponent the best system?

There’s no way around GetComponent in that case.
If the proximity doesn’t change that often it’s probably way easier when each unit simply holds a list / Dictionary of all units in proximity. So inside the OnTriggerEnter callback you ue GetComponent, get the reference you need and store it in the list or dictionary ( use the collider as key ). In OnTriggerExit you remove the unit from the list.