When Switch Turn On
Fires when the switch changes to the ON state.
Introduction
When Button Down is an event in the Switch group of World Events. It fires when the switch changes to the ON state. When it fires, the event hands one value to your script: Player, the player who interacted with the switch. Like every event, it does nothing by itself. It waits for the right moment, then runs all the actions connected to it. This event belongs to the Switch component. Open the Switch component guide to see everything the component itself can do. A switch always has two states: this event fires when it flips to ON, and When Switch Turns Off fires when it flips back - use the pair for doors, lights, and machines with an on/off behavior. For zone-based activation without a physical switch, compare with When Trigger Entered , and the switch itself is configured like other interactive props described in the Object Logic guide. When Switch Turn On event in the World Editor Image The When Switch Turn On event in the Script Editor. caption
Parameters
Player the player who flipped the switch to ON Parameter Description
How to Access
How to Access - Event When Switch Turn On
How to Use
Select the object, press Propertie (the blue equalizer icon) in the bottom action menu, and scroll to the bottom of the properties panel. Press Add Component and pick the Switch component; its block stacks below the existing properties with the When Switch Turn On event inside it. The component has exactly two events, When Switch Turn On and When Switch Turn Off : On fires when the switch is flipped on, Off fires when it is flipped off. Press the + button below the event to add a script, then press Edit on that script to open the script editor and build the actions that should run when the event fires. Press Play and flip the switch on, then check that the actions run.
Example
When switch turn on by Player: Execute Player, Player.Controlled Character.Character.Play Animation when-switch-turn-on-example.png Plays an animation on the flipping player when the switch turns on. caption
Common Uses
Open a door while the switch is on Start a machine or a conveyor belt Activate a trap when someone steps on the switch
Tip
Use When Switch Turn Off for the off moment, together they cover both states of the same switch.