Design, where to script levels if not in level blueprint?


I am fairly new to Unreal engine blueprint, but em experienced c++ programmer.

So the question is:
Where do you script level specific stuff?

There is a Button actor, and i want to call some actors OpenDoor function, or some other actors ToogleRoomLights function.

Lets say a room has door, window, lights, blending machine…
Id go about this in Level blueprint with RoomEvent with Name parameter.
Do a switch statement on the name, case ‘OpenDoor’ id make it call the door actors OpenDoor function, case ‘ToogleLights’ id call lights ToogleLights function… very simple easy, and fast.

And then the button, i can easily add the button to the level, when it’s pressed have it run the level blueprints RoomEvent and pass the variable name to intro the RoomEvent so i can pass ‘OpenDoor’, ‘ToogleLights’, ‘BlendFruit’.

But it looks like in Unreal engine you should make specialized button actor for each case?
Have the button hold actor reference upon which to act, and have dozen different button actors for one room?

Not being able to reference Level blueprint, how do i go about this problem? just make dozen button actors for each case? or how do you do it in Unreal engine?

You can’t access the contents of the level blueprint but you can still access all of the individual actors placed in the level. As a result you could use tags, an enum, a manual check for all actors of class within a radius, etc to find the actors in the level you want to manipulate.

Not that I’ve even made a button before, but the way that I would go about it is like this.
Make the button actor and add a public actor array variable. Bring it into the level and assign actors to the array.
Then you make an interface blueprint
Then whenever you trigger the button loop through the array and send out an interface message. call it action or something generic. So that way whatever you assign to the button does it’s own thing with the same command. Doors open and close, lights turn on and off, ect.

If the door and light switches need to look different and play different animations you could parameterize that, but using child actors may be the way to go.

What you mentioned i would have done, but multiple inheritance isn’t a thing in Unreal engine. My doors and windows inherit from Destructible already. The light and electrical application inherit from ElectricalGrid. So i don’t have that option.

My last resort is experimenting with Event dispatchers and callbacks, or using tags as suggested.

Trying to hack something in, i’l report progress.

So i ended up using Actor tags.
I tried searching are there limitations on actor tags, but i doubt i will be using more then 100 unique actor tags per level.

I made Actor WorldLevelName which holds logic for specific level. I script in this actor what happens when any specific tag gets called E.G:“RefineryToogleLight2” it pretty much accesses actor with specific tag, and toggles it’s lights.

And button just has Name “RefineryToogleLight2” variable which to send to Actor WorldLevelName to act upon.

Flexible, dynamic, but also potentially buggy AF, but that’s what am going with! Cheers on help!

Glad to hear you got it up and running!