In the blueprint tutorials, when player overlaps two trigger boxes of identical blueprints that activate input to toggle, input only works for one. Why? How to make both work at same time?

Just starting out with UE and I’m going through the “Introduction to Blueprints” tutorials. Just finished no.7 https://docs.unrealengine.com/en-us/Videos/PLZlv_N0_O1gY35ezlSQn1sWOGfh4C7ewO/EmvekeKk-0o where I have to make a blueprint of a light fixture that has a trigger box. When the player enters the trigger box, a prompt to press “F” to toggle the light shows up. Pressing “F” while in trigger box will then toggle light.

All is working fine, but I noticed that because I have 2 of these light fixtures in my level in close proximity, my player can overlap the trigger boxes of both at the same time. When this happens, pressing “F” only toggles the light attached to the trigger box I entered last (and when I leave that last trigger box but remain in the first trigger box, then I toggle the light attach to the first trigger box). Why does this happen and how can I make it so both are toggled? It’s more than anything just to learn a bit more about how blueprint and UE work.

This is a screenshot of the event graph I made by following the video, though I made minor changes that shouldn’t affect this.

Edit:

Huge mistake on my part - This would be right if you were storing the lights in the character.

Try one last thing:

Please select the input event “F” and in the “details” tab make sure that “Consume Input” is not checked.

Old:

You are using (and storing) a single SpotLight variable.

This means that you set it once and then override it with the next set node. This way you are storing only the last object you have set.

In order to start/stop multiple lights you should convert this variable to an array and on KeyPressed F you should loop through the array and toggle the visibility of all of them.

I kinda get what you mean. There are a couple of things I still don’t get though.

  1. What do you mean by set/stored? Where is this object being stored and why can only one at a time be stored at wherever this storage is (without an array)? Are the two separate instances of the same blueprint of a light fixture not considered separate and are thus fighting for the same single available storage space? Is that how it works? Because my default thinking was that these are two separate instances that have their own toggle visibility node that can both store their own spot light and also be triggered at the same time. Am I just clearly wrong?

  2. If the first object is overridden when I enter the trigger for the second object (thus making toggling the first one currently impossible), why am I then able to toggle the first object again if I leave the trigger of the second object all the while never having left/re-entered the first object’s trigger? How did that first object get stored again? When you say overridden, is that not the same as being replaced?

Also, I just tried an array and couldn’t get it to work (keep in mind I just learnt how to make one). What I did was add the spotlight to the array when I enter the trigger box and removed it when I left. I then loop through elements to toggle visibility when F is pressed. This does not change a thing. I also used print screen to show length of array when I enter and leave a trigger box. Most notable is that when I enter the second trigger box while staying in the first, the length is apparently 1. Similarly, when I am in both trigger boxes and I leave only one, the length is apparently 0. So it seems as though the objects act separately when it comes to the arrays, but not input. But perhaps I haven’t done it correctly. Is there a way to make an array that can take the light component of two objects?

These are the nodes I added to my old blueprint.

i feel like this is all being over complicated. your lights are all made as a actor and you are just creating many instances of the one actor right? if thats the case and your overlapping two actors at once and you want the input to affect both at once then theres a simple solution, select the F input event then go to the details panel and uncheck consume input. that should solve your issue by allowing multiple actors that have the same priority to use the F input at the same time.

I am truly sorry.

I assumed that this blueprint is in your actor as I was not too careful watching the tutorial video. I thought you were trying to save references to your spot lights in your character to activate them. I see this is not the case.

I have revised the answer.

Perfect! Exactly what I was looking for, and so simple. Didn’t know there was a priority thing for input events. Totally get it now. I should learn to pay more attention to the details tab. Thanks

Mate it is all good. I learned to make my own arrays in blueprint because of you so don’t sweat it. But yeah your revised answer is what I was looking for. Appreciate the help.