First Person Exploration Kit: Creating a Simple Toggle (Light Switch)

Toggles are a special kind of Activate object that use the TOGGLE Event Fire Type. Please refer to the general Activate Type documentation for more details on various Activation types available in this package.

Creating a Light Switch

  1. Create a Cube, and name it MyLightSwitch.
  2. Scale the Cube to (0.2,0.2,0.2).
  3. Give the Cube a Material such as the included DemoToggleOff.
  4. Create a child Sphere of MyLightSwitch, and name it LightBulb.
  5. Assign a material to LightBulb, such as the included DemoToggleLightOff.
  6. Create a child Light (Point Light) of MyLightSwitch, and name it LightSource. Scale it so it looks how you want it to. Then disable the Light component of LightSource.
  7. Select MyLightSwitch, and add the FPEInteractableActivateScript component.
  8. Configure the Inspector values as follows:
  9. Run the scene, and interact with the MyLightSwitch object. The light will toggle between on and off states. If you save and load the game, the switches states will also be saved and loaded.

Here is a screenshot of the completed Inspector value assignment:

Here is what our simple toggle looks like in game in the Toggle On and Off states: