Activate N of switches to open a door

Hello everybody, I’m trying to make a MULTIPLAYER game where you have to activate a number of switches in order to open the exit door, for instance if one player activates one of the switches, the server knows that one switch has been activated.
What I’ve done:

  • The switches are activated by the E button and cannot be deactivated
  • When a switch is activated, a green light turns on
    What I’m trying to do:
  • When one player activates one of the switches, the server knows that one switch has been activated and keeps tracks how many are left.

Thanks in advance to the people willing to help me.

Depends on your implementation.

One easy way would the door to have two integer variables “NumRequiredActivations” and “CountActivations”. On each button press simply increment your counter and open the door when CountActivations >= NumRequiredActivations.

Another way would be the door to have references to all the buttons in an array. On a button press let the door check all buttons for its state.

Thank you for taking your time to answer my question, the point is I’m not sure how to do it, do I need to use a specific blueprint in order to be able to send the integers between the buttons and the door?

Nevermind, I found a solution, it’s really simple: you have to call all the actors (switches) into the level blueprint.

Actually I would not use the level blueprint.

Just give the switches a variable “TargetDoor” and make it instance editable. You can then pick your door in the properties panel in the world outliner.

Take a look at the BP_Button blueprint from the Content Examples. They are also using a blueprint interface to decouple the BP_Gears from the BP_Button, so the button can activate any BP that implements BPI_Interactions and not just gears.

Thank you, I did what you suggested: I scrapped the code I made in the world blueprint and followed the same mechanics of the BP_Button and BP_Gears using a BPI.