How to create a switch sequence for door

Hi there,
I am new to using UE and development for games and was wondering if anybody could provide any methods on creating a sequence of switches in order to unlock a door. I have managed to create one for a two button floor system to open a gate but am struggling a bit wit the switch one.

What I want to achieve is a system in which the player can turn on a switch in whatever ever sequence they want but it has to be a specific sequence in order to unlock the door. There are three switches overall.

Here is my script for the floor system I created:

http://prntscr.com/jhb9fv
http://prntscr.com/jhb9j5

in the pictures below you will find a quick method i just made to accomplish what your looking to do. to do this i first created two blueprint actors one called DoorSwitchTest and another named switches. now i started out with setting up the functionality of the door. first i created the variables i was going to need, i created 3 variables named switch1, switch 2, and switch3, and i made them the type switches object ref (this is done in the details panel with the variable selected). the last variable in this bp is a an array of type switches obj ref named locksOrder. next i created all the custom events we would need (setSwitch, TestSwitchOrder, ResetLocks, and UnlockDoor). We also need to set an input parameter on setSwitch, to dothis just select the event node and go to the details panel and you will see inputs, from there click the + icon, this will create a input parameter, you set this up just as you would a variable. from here we can start setting up the graph from set switch i used a multigate so each time the its activated it will use a different pin, this makes it easy to set the variables in a specific order. speaking of which we set the variables here and after the third is set then we move onto the testing phase. this next part is where we ensure that the switches were activated in the correct order. we first make sure that 3 switches were activated using the is valid and a branch, then we compare the the switches that were activated to the order of the ones in the array. As a quick aside i set the array varaible to public so that i could fill in the values via the details panel once the door was placed in the scene, this allows us to reference the switches that are placed in the scene. ok so if the switches were activated in the correct order the branch will be true and will execute the unlock door function, but if they were not in the right order then it will execute the reset locks function. the reset locks is pretty simple it calls a custom event in the switches (i made this so the switches would change color and become inactive once used) then it clears the variables value.

in the switches bp i added a box collision and a cube so it can be seen in the scene and so it can be overlapped. i also created a variable of type doorSwitchTest named DoorAssociated and made it public. i did this so that i can have a reference to the door bp that i want to be setting the switches on, its like the array in the door bp you set in via the details panel with the switch selected in the scene. ok now the script. i used E as a use key to activate the switch, at which time it makes sure that the player is overlapping the switch. if the character is overlapping and the e key is pressed then we call the set switch event on the door. one more thing to note you will need to select the E input and go to the details panel and uncheck consume input, also go to the class defaults and set auto recieve input to player 0.

if you have questions let me know and ill do what i can to answer.

1 Like

Thank you for your support and time in helping me, I appreciate it.