Is it possible to target multiple targets but not all?

let’s say i have 20 instances of a light in the level and a button, but i only want that button to target 3 of those lights, is this possible? ideally i would like to expose a variable on button which could either set a group actor that holds the lights to target or just be able to attach the lights to the button and just reference all of the buttons children as the target. I have tried multiple ways to get this effect but it does not want to work.

Would i have to create a variable on the button and lights called “group” or similar and just have the button message all 20 lights then each light check if the buttons “group” variable matched their own and turned on/off or not accordingly?

I assumed that way would work (its what I was getting at in my last paragraph) but figure its going to be resource hungry as you are fetching all in the level and sending a call to each, I was hoping for a cleaner solution. Hopefully there is a way but if not thank you for confirming that solution would work.

You could probably do this with broadcasting a message or event, but an easy way is to:

  1. Use “Get all actors of class” node to get your lights blueprint class
  2. Use a ForEachLoop node
  3. Check each one to see if it has a tag representing the group of lights you’re wanting to affect or you can create a String variable on your lights blueprint to represent a Group Name or a Zone Name and then check the value of that.

I did something similar in wanting to activating a group of turrets. I set up a trigger blueprint that would check the distance to the player and then it would activate a group of turrets. Take a look here…should be similar:

You’re probably ok with this approach unless you have tons of lights in the scene or if you are turning them on and off very frequently.

In case your solution below doesn’t work out, you could also create separate light blueprints for each of your groups. Using inheritance, you can just base them all off your base light blueprint. This would let you just grab all of the lights of a specific BP without having to check for a tag or a variable.

But unless you’re dealing with hundreds of lights, you’re probably ok just checking the tag or variable. Optimize it by creating blueprint variables if necessary, but that probably isn’t the best practice unless you really see a performance hit.

I may have came up with another solution, daisy chain them together. Button activates light 1, light 1 activates light 2 etc. Its more convoluted than I was aiming for but would do the trick. Look forward to see if anyone has a better solution.

Something like this? GroupLight - YouTube
I’m pretty sure that there is a whole bunch of ways to do this depending on what exactly you need. I like Multigates for quick fixes.

did you try the ‘sequence’ node yet? you can route a single signal to multiple targets with it.

I could hard code the targets into the blueprint or have a set number of targets a button can have but the idea is to be able to easily modify its targets and without having to go into the blueprints and in a sense have unlimited targets, which is why I was trying to use attaching or groupactor. Its not looking likely so this may be an option. Thank you.

This is an option but it takes away the flexibility of being able to target multiple actors without modifying the code.

There will be heavy use of this code in the project I’m working on so I’m trying to minimize overhead by only making calls to the required actors.

Well i feel stupid, i completely forgot that it’s possible to set the variable that’s exposed to an array, this does exactly what i require, so now i can setup the button, and then choose as many targets be it a light or other element. here are a few pictures to better show the setup and what i was aiming for.

Hopefully this helps someone in the same situation

hi glotty, can you explain how and where you exactly exposed this variable?
because i need to get a location of a blueprint that is placed into the world, to use this location in another blueprint. can i do this with your array technique?
thx man!

Hey there, there’s a few questions I need to ask, is it a blueprint that is likely to move? And are you going to create the link at level creation or dynamically during play? There are so many ways you could go with this I just want to make sure I give you what solution is best for your situation. Also it’ll give me time to get home and put something together :slight_smile:

ah cool that you take the time! (perhaps i should ask a new question and you could answer there?)

issue 1) i place a directional light into a solarsystem at the sunposition (not center of world)
the light direction of this light should be always towards the spaceship which is controlled by the player.
so the directional light needs to get the position of the moving spaceship in order to update its direction. how would i propagate the dynamic world position of the spaceship so that the directional light can get this info?
issue 2) i have static atmosphere halo’s where the fresnel should be masked by the static sun position. so not facing to sun=no halo.
how can i propagate the sun position to use it for a material calculation.
i can achieve the effect, when the sun is at the center of the world, but now we have different solar systems all around the level and i need explicit coordinates for every single sun that is in our solarsystems
alternatively i could use the center of the solarsystem blueprint where the planets are placed into (would be the better alternative i think)
the picture shows the approach for a fadeout based on the world center.

  1. everything you need is in Blueprint office(the marketplace example) inside of the security camera blueprint, it shows how to set the player location, and alter the cameras (or in your case just the light) rotation to face toward it (ill not pretend to understand the math behind it, math was never my strong suite).

  2. i doubt i can help much i’m just learning the material system, but i assume the same approach in 1 can be used to help here to some extent.

I don’t mind helping at all, i find it a good way of learning, the material thing is a bit out my league at the moment but it will be a good practice experiment when I get to the right understanding of how the material system works.