Profile Photo

Unreal Engine 4 – Programming Lights with Blueprint

Are you ready to program some lights?

Here’s how you can use the BLUEPRINT system to program your lights and switch them On/Off every time you enter an area. Remember these can be programmed as buttons or collision areas – check it out in the video below or follow along the instructions in text:

There are two ways to program your scene, by either using the Level Blueprint or at the individual actors’ blueprint. The Level Blueprint houses the programming that runs for the entire level, while the actor blueprint is specific to that actor only.

We’ll program the lights in a way so that every time we stand next to them we can either have turn on or off automatically while moving about in the scene. In order to program the light, make sure its mobility is set to’Movable’. We’ll add a spotlight mesh in the scene and adjust its position, rotation, and scale to our liking. Let’s define the blueprint creation process in the following steps:

  1. Select the spotlight mesh, and click the ‘Blueprint/Add Script‘ button on the right in the Details tab. This opens your Actor Blueprint.
  2. In this Actor Blueprint window, click ‘Add Component‘ and choose the Spotlight type of light source. This will add the light into the blueprint as well as the scene and links it to the mesh. Use the transformation tools to align it correctly to the static spotlight mesh. Moreover, you can set the intensity, color, and an IES texture to your liking.
  3. Next go to the Event Graph to begin programming the light logic. Right-click to search for and add ‘Event BeginPlay‘. Connect it to the ‘Set Visibility (Spotlight)‘ function, with the visibility ticked off.
  4. Now let’s add a ‘Trigger Box‘ right below the light. With the box selected, open the Level Blueprint and drop in ‘Add On Actor Begin Overlap‘ collision event.
  5. Select the spotlight in the scene and then go back to the Level Blueprint. Right click and select ‘Create a Reference to Your Spotlight Blueprint‘. Connect this again to the ‘Set Visibility (Spotlight)‘ function and turn visibility on.
  6. Link the main node of the trigger box event we added earlier to this Set Visibility function.
  7. To turn the light off after leaving the area, drop in another ‘Add On Actor End Overlap‘ collision event in the Level Blueprint. Add a ‘Set Visibility‘ function using the same Target node and link it to the End Overlap event. Turn the visibility off for this one. Compile and Save.

 

Hope you’ve enjoyed this tutorial. More stuff coming up – such as opening doors, switching textures, effect with coffee steam…and more!

If you wish to learn more, check out our UNREAL ENGINE 4 Workshop here.
Share it – Like it 🙂

Talk soon,
Alex

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
© Arch.Viz. Online School 2014
Join the
GREATEST MAILING LIST
Be a part of Smart VRay Workflow
Stay Updated
Give it a try, you can unsubscribe anytime.
close-link

Login

Create an Account Back to login/register