Game Logic question, the trigger and the door

Hi!,

It is not the name of a new movie :), but I’m curious how people handle this kind of game objects talking one to another in unity.

In the past (C++ age), I have been doing this using some sort of signals (observer pattern) or monolithic event manager. With unity component arquitecture perhaps there are a more direct way to do this. Could anybody explain how do they setup in the editor/ handle this situation “When player enters the trigger, the door opens”?.

Thinking myself about it, just come across about having a script called EventTrigger where you can drag gameobject to an array it publishes, and in the OnEventTrigger an event is sent to all subscriber. The event action can be given in the editor too.

Anything better? or Any other way to do this with the power of unity?

Thanks in advance,
HexDump.

Using JS, I just establish a link from one script to another, like this:-

private var theScriptiWantToAccess : theNameOfTheScriptiWantToAccess;

function Awake () {

	theScriptiWantToAccess = FindObjectOfType(theNameOfTheScriptiWantToAccess);

}

Then when I want to do something in the other script, I use:-

theScriptiWantToAccess.theVariable = 100;