How do I make a Button Sequence in UE4 4.21?
I am looking to create a basic button sequence in UE4 for a game. I have no idea how to even remotely start this.
I would like it to be, Press Black Button > Green Button > Blue Button > Door Opens. The door will be using a Matinee animation.
Can anyone show me how to go about doing this?
asked Mar 30 '19 at 12:14 AM in Blueprint Scripting
this is actually much simpler that it seems. in the below explanation and example im using a generic switch and door lock system. ok so the basic idea here is that you have multiple switches, one door, and must activate the switches in the proper order to open the locked door. for this example we will be using two bp actors, one for the switches and one for the door.
the main actor here will be the door which is the first picture below. to begin we will need two variables of type string (you could use a different type), one variable will hold the correct combination (correctCombo) and the other will hold the combination to be tested as entered by the player (TestCombo). you will want to make the correctCombo variable public so you can set it in the level editor on a per instance basis, this is so you can have many of this type of door in your game and each can use a different combo. next we will need 3 events: AddInput event will add to the current testCombo variable, CheckCombo Event will check to see if the test combo is correct, and open door event will open the door. ok so we will begin with the addInput event, this one is pretty straightforward begin by selecting the event and in the detail panel add a input paremeter of type string, then get a reference to your testCombo variable, drag off the test combo get and search for append, connect he test combo and the input to the append, set the test combo to the new value, last call the checkCombo event. for the checkCombo event drag in both variable and for each one drag off and search for length, this will get the length of the string, then get a equal node (==) and a branch so we can compare if they are the same length, this is our first condition and will make it so the combo is only checked when the number of switches is right. next we perform the actual check of the variables, get a reference of each one again and again dragg of and use a equal node ( this will be a string = string so its a little differnet from the last one). if the branch is true then you know the combo entered is right and you can open the door (call open door event), if its false the combo is wrong so you need to tell the player that (play sound, notification, etc) then clear the variable so they can try again. the open door event i just added for completions sake, for this i used a timeline to drive the movement via a float track 0-1 value over X seconds, then set the relative rotation accordingly. compile.
the second picture is the switches. for this actor you will need two vairables again. one string type (input value) which will be what the switch will add to the combo so colors or letters or numbers whatever you like. the second variables type will be of the class of your door, in my case the doors class is 111door, this variable will be a reference to the door that you are looking to open/enter combo to/ target. both variables are set to be public (represented by the open eye) so that we can set them in the level editor/viewport. now for the script we first need a way to activate the switch, in my example i used a key input Q. next we get the door reference variable, drag of the variable and search for the addInput event we created earlier, nex we plug in the inputValue variable to the input pin. thats it, compile this one.
the last step is to set it all up in your level. first place a door in the level and with it selected go to the details panel, in the default section you will see your correctCombo variable, enter in what you want the combination for this door to be. also while the door is selected take note of its name in the outliner. next place some switches in the level, for each one you place select it and in the details panel set the variables for the switch, you will need to set the associatedDoor to the one you just placed in the level, and set the input value to what you want this switch to add to the combo.
answered Mar 30 '19 at 02:03 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here