Creating a switch to open and close a door

This example shows detailed steps to get a switch to control a door.

For this example open or create an island level. If you create an island you may have to save and then reload the island for this to work.

In this example we will place a shed in the level, place a switch, rename the door of the shed so that we can reference it from the switch Procedures, set the door to be locked and not pick able, and then configure Procedures on the switch to open and close the door.

Placing a shed
Follow the Placing a builder prefab instructions to place the Shed builder prefab located in the Town sub folder.

Placing a switch
Follow the Placing an object instructions to place the Floor_Level1 switch located in the Switches sub folder. Place it outside the Shed near the the door to the shed.

Editing door properties
Follow the Selecting a builder instructions to select a builder to work with and then follow the Selecting a builder object instructions to select the door to the shed. Press the edit object button to edit the Door Properties. Change the door s Status to Locked and uncheck Can be picked. This will make it so the door can only be opened using the switch that we are going to set up. Then change the name of the door to something easy to find in case there are a lot of doors in the level. For this example rename the door to Shed door.

Making the switch control the door
Follow the Selecting an object instructions to select the switch you placed. Then press the edit object button to edit the Switch Properties. Click on the ... button next to On Activate Start to open the procedure. The click the Add decision button to add a Decision to this Procedure. The click the box under Action if true to set the action for this decision. This opens up the Edit Actions dialog. Press the Add action button and select the Change door state action. Edit the door state action that is created. Select the Shed door for the Door name and set the Door state to Open. This will open the door when the player starts to activate the switch.

You can also make the switch close the door by clicking on the ... button next to On Deactivate Start to open the Procedure. Follow the instructions in the last paragraph but set the Door state to Closed instead of Open.

Test
Hit the play button detailed in the Editor Interface overview. Walk or run to shed and try to open the door. You should not be able to. Then interface with the switch and the door should open. Interact with the switch again and the door should close.