Game Development Reference
In-Depth Information
Illustration 41:
Light switch trigger completely configured
Illustration 41 shows that the trigger has two states. The first state sends two messages
when activated:
SwitchOn
message to
ControllableLight
, and
Flip
message to
LightSwitch
.
ControllableLight
is the light game object that has the script
LightControl
, and
LightControl
is the switch object itself. This means that the trigger sends
Flip
message to itself. The
second state also sends two messages when activated. The difference is the message it
sends to the light, which is
SwitchOff
this time. At the beginning, the light is switched on,
therefore we set
currentState
to 0, which is the first state. To complete the functionality,