I’m very new to using unreal and was wondering if anyone knew of a simple way to make the lighting dim a little more each time the player runs into a trigger box. I’m using the First Person Shooter template and have damage trigger boxes set up and just want to add the effect of the room getting darker each time they hit that trigger box as well.
Hello, I’m also still a novice at unreal so there might be better ways but I was able to make this method work. I’m not sure how new you are so I’ll try to explain everything as understandable as possible.
- first create a blueprint of the actor kind.
- When you open that blueprint on the left side you can add components. click on that button and type “light” in the search function.
- In this example I used a point light. If you click on the point light after adding it you can change some stuff.
- For this example, change the intensity to 50000 to make the light more obvious.
- then add a collision box the same way as you did the lights.
- In the viewport you can change the location of the hitbox if you want. Just select the hitbox component and use the widges to relocate.
- When you select the collision box and scroll down in the details tab (it’s on the right if you still have the default screen setup) You’ll see a couple of green buttons under “events”. Click on the “component begin overlap” button.
- This will take you to the event graph where you have just created an event node. From that node you look for the other actor pin and left click and drag to pop up a menu. You can use this menu to create other nodes.
- type “first” into the search bar and select “cast to First person character” We use this casting node to make sure that the light will dim only when the player is overlapping.
- Make sure that the node is properly connected to the other actor pin and the execution pin (the white arrow on the top). If a node has an execution pin on the top left side but is not connected that node will not activate.
- From the right execution pin of the “cast to first person character” you click and drag to again have that menu and type in “do once” in the search bar to be able to select the “do once” node.
- This node makes sure that whatever happens will only happen one time.
- Now look on the left of your screen, you’ll see some headers. Look for the “variables” header. Under there you should be able to find the point light. Hold down ctrl while you click and drag the pointlight into the event graph to get a reference node. This can be used to change the properties of the pointlight.
- Click and drag from the pointlight node to get the node menu and type “get intensity” to find that node.
- Now you’ll see that the intensity pin will have a different color (it should be green). This is because it’s a different type. If you want to know more about type then this link should prove usefull: https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Variables/
- Drag from that intensity pin and type “-” (the subtract symbol). then create the “float - float” node. Make sure the the intensity pin is connected to the upper left pin of that node.
- On the pin below that you should see a “0.0”. Click on that and for now fill in 25000 (do this only if you have the intensity set to 50000)
- Then go back to the “pointlight” node, click and drag of of it again and type in “set intensity” and create that node.
- Connect this node with the do once node via the execution pins
- Then take the right pin of the “float-float” node and connect it to the “new intensity” pin of the "set intensity"node.
- Next select the collision box component from the components tab (upper left). Then go the the details tab and add the “Component on end overlap” event node by pressing on the green button.
- Add a “cast to first person character” node and make sure that it’s connected.
- Then connect the execution pin to the “reset” pin on the “do once” node.
- Remember to compile and save, you’ll find these on the upper side of you screen.
- Go back to the game view and drag the blueprint into the world.
- No when you press play and move your character inside the collision box the light should dim and if you reenter again it should go out.
You can re balance the dim effect by playing with the intensity value and the value you subtract from it. I’ll add some pictures as reference. Feel free to give feedback on my explanation or if you have other questions. I’m still a novice myself but I would be happy to try!