Construction Scripts
Door Lock Status Indicator with a Point Light
STEP 01
Add a Point Light to the Door
- Select the door's cube component in the viewport.
- Go to the Components panel and add a Point Light component.
- The Point Light will be parented to the cube automatically.
- Position the light at the front of the door.
- Adjust the light's radius to a suitable size.
STEP 02
Use the Construction Script to Set Light Color Based on Door Lock Status
- Open the Construction Script tab in the Blueprint's Event Graph.
- Drag out the Boolean variable that indicates if the door is locked (e.g., is locked).
- Drag out the Point Light component.
- Use the Set Light Color node to change the light's color.
-
Use a Select node with the Boolean as the condition:
- If true (locked), set the light color to red.
- If false (unlocked), set the light color to green.
- Compile and save the Blueprint.
- This setup will update the light color when the door is created or edited in the editor.
STEP 03
Update Light Color During Gameplay
- Go to the event functions for locking and unlocking the door (e.g., Lock Door and Unlock Door).
- Copy the logic from the Construction Script that sets the light color.
- Paste this logic into both the Lock Door and Unlock Door functions.
- Connect the is locked Boolean to the Select node to determine the color.
- Compile and save the Blueprint.
STEP 04
Test in Game
- Play the game and observe the door's light color.
- When the door is locked, the light should be red.
- When the door is unlocked (e.g., by pressing a button), the light should change to green.
This tutorial helps visualize the door's locked status to the player using a colored light that updates both in the editor (via the Construction Script) and during gameplay (via the Lock Door / Unlock Door event functions).