I want to control all trigger points separately. For example, if I go to trigger point 1, then only the lamp at trigger point 1 should light up. The way I built it works, but there must be a more elegant and simpler solution. Can you help me?
Hey @Abaddon-91! Welcome to the forums!
Actually, for Level Blueprint graph, this is rather simple and elegant.
It just looks weird because of the shapes. You could also spread things out a little bit, or use a condensed graph here and there. But this is pretty small and simple, and lacking spaghetti, no need to refine further.
Hope that helps!
Welcome @Abaddon-91
Sure you can. You could build yourself a new actor class that would be your trigger and you could re-use it for each light. You will also be able to specify from editor, which light to control using picker tool.
Create new blueprint class of type actor, lets call it BP_LightTrigger, add a box collision as root component (or use sphere/capsule if that’s what you want).Give it a size say 100x100x100.
You can also add a billboard or arrow component to make it easier to click on in the editor, instead of having to select the actor in outliner or trying to click on box collision line. Make it a child component of box collision. It should be centered when you add it. In details panel for this billboard, search for hidden in game and uncheck that box.
Add a new variable, lets call it “Point Light Control”. As type search for Point Light, then pick reference (top option).
In details panel for this variable, check boxes “Instance Editable and Expose on Spawn” this will make it possible for you to select which light you want to control from the map editor itself.
Right click on Box Collision component and Add Event’s
On Component Begin Overlap & On Component End Overlap. It will place two nodes on the graph.
For each of these nodes, drag off “Other Actor” pin and do == sign.
Right click on the graph and “Get player character” and plug it into other pin on both of your == condition nodes. Now create two branch nodes and connect the condition to each of them.
For both branches on true, get your Point Light Control variable and place it on the graph, drag off it and search for Point Light Component. From that component find Set Light Color. You need two of these, one for when you enter the Box Collision and other for when you leave (assuming you want to restore the color when leaving the collision). Set your colors are you prefer.
Make sure all blueprints are compiled and saved.
Place BP_LightTrigger in the level, select it and in detail panel you should now see field called “Point Light Control”. Click on icon then click on Point Light in your level you with to “assign” to that Light Trigger.
Start the game, walk into your collision and the light should change color when you enter and change back to whatever you set it to be on End Overlap.
Below some visual aids.
You could go further and customize it as much as you like, have it control multiple lights at the same time, have a dynamic color picker for light color or whatever else you desire.
I did add two more variables for myself, so I can control if Billboard component is hidden or not in the game, as well as Box Extent vector so I can control the size of Box Collision from the editor.
Let me know if you have any questions.
While I know I said what I said, that does not disagree with DonBusso’s answer. They are for two different use cases. If you are only using this mechanic in this level, and do not plan on reusing it often, I believe you should leave it as is.
However, if you are planning on using it multiple times in multiple cases, follow DonBusso’s advice here. Reusability is VERY good to have, and the more often you need to reuse the code the more time you save.
But like I said, if you are ONLY using that here, it would actually take MORE time to do what they suggest because throwing three lights together in the Level Blueprint is pretty dang quick.
Regardless of what you do, I’d suggest trying out DonBusso’s way here to widen your options, this is absolutely not limited to lights! This is a HUGE concept for level building and mechanics!
You’re making a good point. Thanks for clarifying! I believe it’s up to us, helpers, to show them a little bit more at times so they can make better decisions or possible inspire them to do more!
Simplistic one off usage with small number of lights/triggers… Go with what you have. I’m with @Mind-Brain on this.
However if you have many, or used on many levels go with @DonBusso approach. Fully encapsulated actor. Use a Box collision component and Light component in the class. You can then customize every single aspect of the specific actor to your needs.
Drag and Drop in the level. While selected click the collision component, move and scale it as needed. You do not need separate actors to get the desired functionality.