Windows Switches that activate objects

Hi, I'm trying to figure out what method is best for creating a kind of generic switch object that activates or deactivates another. So if I have two objects, a switch and a door, what would be the best method of "connecting" them?
Currently I place an instance of a switch object and then in it's creation code make it create an instance of a door at a specified location and save it's ID which works fine but feels wrong.
I've tried searching around but you obviously get a load of different results when searching for switch.
Thanks in advance.
 

obscene

Member
You can also use creation code to give doors and switches a matching "key" variable. Then in code you do something like....

with obj_door
{
if key==other.key
{
// open
}
}
 

TheouAegis

Member
But having the ID of the door to target already stored in the switch will be faster. That way you don't have to loop through all doors.

Or have the switch set a global variable and have the door objects check if said variable is set.
 
Top