How do I dynamically assign TriggerVolumes to new PointLights?
Apologies if this is a horribly worded question, but I'm struggling with a project I have been working on.
I'm still fairly new to using UE4! I have a Point Light (PL) and attached Trigger Volume (TV). When entering the TV with a player character, the PL begins to flicker and turn off, with this being reversed when leaving the TV. All of this blueprint scripting is done within the Level blueprint, and will only work with the TV named "TriggerVolume" and the PL named "PointLight".
If I wanted to make a new light that followed the exact same rules, would I really have to copy this blueprint script again, and replace the references to "PointLight" with references to "PointLight2", or is there a more streamlined way of doing this (and less messy!)?
Any help is appreciated!
the simplest solution to the issue in a standard level would be to have two actors, one as the trigger and one as the light. the trigger actor would have a collision volume that when overlapped by the player would use a for each loop to call an event on the light actor. to determine which actors to affect i would use an array of the type of your light actor and make it editable so that when the trigger is placed in the level you could tell the array what to have in it. this is basically what i did in the picture below.
near the end of your last post you said you wanted to do this for a procedural level, this complicates things a bit. where this creates issue is because you dont have static objects in the level to get a reference to. so you would need to make a script to say which lights to affect in the level. for example you could use a get all actors of class then run logic to determine which lights were within 500 units and only affect those. you can make these types of conditions as complex as you like but it will be difficult to get the exact effect you want.
also it depends on how you want to implement the random generation. if you were to create a modular system where have a pre-made room and your generation just places them in random locations then you could just have the logic in the room blueprint modules.
answered Feb 13 '18 at 11:42 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here