Toggling lights through Kismet

In the previous recipe we set a Material toggle using two Set Material actions in Kismet. This only changes the Material on a mesh however, not the light cast in the scene. For that we are using PointLights. However, to make a PointLight so it can be turned on and off, it must be converted to a PointLightToggleable. This is what we'll cover in the recipe, along with setting up a control for this converted light using a simple Toggle action.

Getting ready

The scene we'll work with would take a while to set up, so a starting point has been provided. From the provided content, load the map Packt_04_ToggleableLights_Start.UDK. The scene includes at one end of a passage two switch elements and some lamp meshes. The lamps have a Material with a flickering Emissive channel, but the Material is insufficient to illuminate the surroundings. A standard PointLight sits in front of the smallest lamp, and we'll convert it to a light type that can be toggled in Kismet.

How to do it...

  1. Select PointLight_4 by searching for it in the menu Edit | Find Actors. It is the light at the dark end of the passageway. Right-click on it and choose Convert Light | PointLights | PointLightToggleable. Notice its name and enumeration now change. Making the light toggleable is necessary to let the light operate in Kismet.
  2. Open Kismet [ How to do it... ] and right-click in the Kismet canvas and choose New Object Var Using PointLightToggleable_0. Notice the light has been renamed and renumbered. Its icon [ How to do it... ] has also changed to include a little dangling chain like old style lamps used to have. This reminds us we can switch this light on and off.
  3. Minimize Kismet. Notice it pops down into the corner of the editor. You can actually place this minimized floater where you like and it will remember that position. Place it under the Kismet icon [ How to do it... ]. It will remain there till closed.
  4. Now, we need to toggle the PointLight, which we already converted to be toggleable. This requires only a Toggle action (hold T and click) in Kismet. First, duplicate the PointLight so a copy of it covers the second wall lamp. Create the Toggle in Kismet, and assign the first PointLight as its Target.
  5. Hook up the first Trigger Used event's output to the Turn On input on the Toggle action. Also, hook up the Level Loaded event's Loaded and Visible output to the Turn Off input of the Toggle. Repeat this for the second PointLight using the second trigger so you obtain a network functioning like the one shown in the next screenshot:
    How to do it...
  6. Press Build All [ How to do it... ]. You should now have a scene where the end of the passage is dark, and the two Triggers, when used with E, turn on the lights and depress the switches with a sound to enrich the event. The next image shows the toggling the triggers cause. Notice how the highlighted Level Loaded event sets the initial state for everything. Next we'll set up the Matinee action to control the lights flickering so it matches the flicker built into the lamp model's Material.
    How to do it...
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.53.143