Function execution order ...

If I had the trigger attached to Class B and it has reference to class x. Can class B call a function in class x while class x is running function A ?

Script will execute in a linear fashion. Variables will only arrive when the call is made.

If you declare a variable as type script in B you can execute the function in X while X is running A as the new variable-script will be an instance; i.e a second copy of X.

There are times when variables will not update until frame end but clever use of GetComponent can avoid this.

Also be aware you can use GetComponent to set variables as well as get them.

If you somehow called two functions in a class at the same time, it’s possible they might fight over globals, setting them in crazy ways, resulting in a mess – maybe a “dead” but not deleted enemy that just freezes, blocking the path … . Those type of problems are called Race Conditions. Any time you have Concurrancy (two programs threads running at once,) you have to be super careful, and the pros still get bugs.

So, programs don’t work that way. In particular, Unity does one thing at a time. Say collider A is calling foo in class B which calls bar in class C. “bar” is the only thing going on in the whole computer. Class B and C are doing nothing except waiting. collider A has 0% chance of interfering with C’s business, since C is either completely finished (maybe it got to the end of Update, and quit) or hasn’t started.

Object Oriented programming makes it seem like every class is smart and is doing stuff to itself. But, as far as the actual running goes, they are just dead data. The one Unity thread is always doing one thing at a time.