Using the Trigger Volume to turn on/off light

We are now ready to use what we have learned to construct the next room for our game. We will duplicate the first room we have created in order to create our second room.

  1. Open the level that we created in Chapter 2, Creating Your First Level, (Chapter2_Level) and save it as a new level called Chapter3_Level.
  2. Select all the walls, the floor, the door, and the door frame.
  3. Hold down Alt + Shift and drag to duplicate the room.
  4. Place the duplicated room with the duplicated door aligned to the wall of the first room. Refer to the following screenshot to see how the walls are aligned from a Top view perspective:
    Using the Trigger Volume to turn on/off light
  5. Delete the back wall of the first room to link both the rooms.
  6. Delete all the doors to allow easy access to the second room.
  7. Move the standing lamp and chair to the side. Take a look the following screenshot to understand how the rooms look at this point:
    Using the Trigger Volume to turn on/off light
  8. Rebuild the lights. The following screenshot shows the room correctly illuminated after building the lights:
    Using the Trigger Volume to turn on/off light
  9. Now, let us focus on working on the second room. We will create a narrower walkway using the second room that we have just created.
  10. Move the sidewalls closer to each other—about 30 cm from the previous sidewall towards the center. Refer to the next two screenshots for the Top and Perspective views after moving the sidewalls:
    Using the Trigger Volume to turn on/off light
    Using the Trigger Volume to turn on/off light
  11. Note that LightMass Importance Volume is not encompassing the entire level now. Increase the size of the volume to cover the whole level. Take a look at the following screenshot to see how to extend the size of the volume correctly:
    Using the Trigger Volume to turn on/off light
  12. Go to Content Browser | Props. Click and drop SM_Lamp_Wall into the level. Rotate the lamp if necessary so that it lies nicely on the side wall.
  13. Go to Modes | Lights. Click and drop a Point Light into the second room. Place it just above the light source on the wall light, which we added in the previous step. Take a look at the following screenshot to see the placement of the lamp and Point Light that we have just added:
    Using the Trigger Volume to turn on/off light
  14. Adjust the Point Light settings: Intensity = 1700.0. This is approximately the light intensity coming off a light bulb. The following screenshot shows the settings for the Point Light:
    Using the Trigger Volume to turn on/off light
  15. Next, go to Light Color and adjust the color of the light to #FF9084FF, to adjust the mood of the level.
    Using the Trigger Volume to turn on/off light
  16. Now, let us rename the Point Light to WalkwayLight and the Wall Lamp prop to WallLamp.
  17. Select the Point Light and right-click to display the contextual menu. Go to Attach To and select WallLamp. This attaches the light to the prop so that when we move the prop, the light moves together. The following screenshot shows that WalkwayLight is linked to WallLamp:
    Using the Trigger Volume to turn on/off light
  18. Now, let us create a Trigger Volume. Go to Modes | Volumes. Click and drag the Trigger Volume into the level.
  19. Resize the volume to cover the entrance of the door dividing the two rooms. Refer to the next two screenshots on how to position the volume (Perspective view and Top view). Make sure that the volume covers the entire space of the door.
    Using the Trigger Volume to turn on/off light
    Using the Trigger Volume to turn on/off light
  20. Rename Trigger Volume to WalkwayLightTrigger.
  21. In order to use the Trigger Volume to turn the light on and off, we need to figure out which property from the Point Light controls this feature. Click on the Point Light (WalkwayLight) to display the properties of the light. Scroll down to Rendering and uncheck the property box for Visible. Notice that the light is now turned off. We want to keep the light turned off until we trigger it.
  22. So, the next step is to link the sequence of events up. This is done via Level Blueprint. We will need to trigger this change in property using the Trigger Volume, which we have created and turn the light back on.
  23. With the Point Light still selected, go to the top ribbon and select Blueprints | Open Level Blueprint. This opens up the Level Blueprint window. Make sure that the Point Light (WalkwayLight) is still selected as shown in the following screenshot:
    Using the Trigger Volume to turn on/off light
  24. Right-click in the Event Graph of the Level Blueprint window to display what actions can be added to the Level Blueprint.
  25. Due to Level Blueprint's ability to guide what actions are possible, we can simply select Add Reference to WalkwayLight. This creates the WalkwayLight actor in Level Blueprint. The following screenshot shows the WalkwayLight actor correctly added in Blueprint:
    Using the Trigger Volume to turn on/off light
  26. You can keep the Level Blueprint window open, and go to the Trigger Volume we have created the in the level.
  27. Select the Trigger Volume (WalkwayLightTrigger), right-click and select Add Event and then OnActorBeginOverlap. The following screenshot shows how to add OnActorBeginOverlap in Level Blueprint:
    Using the Trigger Volume to turn on/off light
  28. To control a variable in the Point Light, we will click and drag on the tiny blue circle on the WalkwayLight node added. This creates a blue line originating from the tiny blue circle. This also opens up a menu, where we can see what action can be done to the Point Light. Enter visi into the search bar to display the options. Click on Set Visibility. The following screenshot shows how to add the Set Visibility function to the Point Light (WalkwayLight):
    Using the Trigger Volume to turn on/off light
  29. Check the New Visiblity checkbox in the Set Visiblity function. The following screenshot shows the configuration we want:
    Using the Trigger Volume to turn on/off light
  30. Now, we are ready to link the OnActorBeginOverlap event to the Set Visibility function. Click and drag the white triangular box from OnActorBeginOverlap and drop it on the white triangular box at the Set Visibility function. The following screenshot shows the event correctly linked up:
    Using the Trigger Volume to turn on/off light
  31. Now, build the level and play. Walk through the door from the first room to the second room. The light should be triggered on.

But what happens when you walk back into the first room? The light remained turned on and nothing happens when you walk back into the second room. In the next example, we will go through how you can toggle the light on and off as you walk in and out the room. It is an alternative way to implement the control of the light and I shall leave it as optional for you to try it out.

..................Content has been hidden....................

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