A question on how to open door after switching 2 lights

hello. i have a quick question. i have a closed door and 2 lights. one on the left of the door and one on the right. what i want to achieve is: open the door after the 2 lights are on. i know how to toggle lights on off but i dont know how to tell the door to open when both lights are on.

its a basic door lock switch system. theres many ways to do this but the simplest to understand will be to use a few bools that get set when a light is toggled. as you can see in the picture below we have a begin overlap event which toggles the light on and off and sets a bool variable. anytime a light is turned on we check to see if all are on and if true then we call the open door event in the door.

now building upon that heres a alternative method which can be used with individual bp actors instead of working in the level bp. in this case we will have a actor for the door and another actor for the switch/light. this system will work on the number of switches activated instead of a bools state.

ok so in the door we need to create two int variables, lights required and current lights (i will be using light and switch interchangeably sorry for the confusion). next we will need two custom events, add lights and remove lights. on add lights we want to take the current lights variable and increment it, on remove we do the opposite and decrement. then its a simpe matter of seeing if the current lights equal (==) lights required, if yes we open the door. note that the lights required is public so you can set it on a per instance basis, also instead of equal you could use a greater than or equal to (>=) node.

now for the switch actor. in this one we will need to create one variable associatedDoor, its type will be set to the class of the door actor and it will be a object reference. also make sure you add some kind of collision volume and a point light (your setup may be slightly different on the component bits). ok so here we again have a on begin overlap event which toggled the lights visibility state. then we use a flipflop to call the events to add or remove lights from the door bp. things to note here: the associated door needs to be a public variable to you can select the switch in the level and set the variable in the details panel to the specific door it will target.

thank you very much. that works perfect :slight_smile: