Light is turned on for all copies of it

This is kind of backwards, possibly, but we don’t know because we don’t know where this code is located. Is it on the GameMode, the Level Blueprint, actor?

this is on the light actor

So the “LightArray” Boolean Array needs to be located on the GameMode, I see that it’s a variable on the Actor. Take that off the actor and add it to the GameMode, you can always cast to GameMode to get it with 0 overhead cost. We want it to be one array accessed by all lights, so we only want one LightArray. If it’s on the actor, each one will have their own LightArray and it won’t work. :slight_smile:

The “GetGameMode → Cast To GameMode” should be before “Set Array Elem”, you pull off of “As GameMode” to “get LightArray” once the Gamemode HAS that variable, then plug that into “Target Array”.

sorry this is really confusing without the actual blueprint as an aid, this is what I have so far

In the Actor and LightArray is in the Game Mode itself - is this all I need to do? how do I then ensure each light is working independantly?

The “Light Index” is how you ensure each light works independently!

Firstly, you ensure that the Light Index variable is set to “Public”. That’s the little eyeball icon, make sure it’s open. This is done in the Light BP.

Next, you bring the lights into the level or find the ones that are there already.

Find them in the world, and when you select them you go into their details window and you should find the “Light Index” integer variable. You can set it there, give each light a unique index, and make sure the array is given a length long enough to accommodate all of the lights. Don’t just set random numbers because it will only accept numbers that your array has room for. Just use 0 as the first one and go up one per light. So if you have 20 lights, they should have numbers of 0-19, individually. This way, you can have infinite copies of the same light, but each one has its own identifying number in the level. :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.