How do I create keypad widget to unlock safe?
I'm trying to create a widget for a keypad that unlocks a safe. I have the basic logic and the widget made, but I need to know how to do the following: Set the 4 digit password, make the keys function, whenever you type a number it shows up on the screen, resets upon failure, sound effects upon entering key, failure, and success, and a way to close the widget by either walking away from it or pressing "E". Any help would be greatly appreciated.
asked Feb 10 '19 at 12:42 AM in Using UE4
so you basically havent started then huh. below you will find a basic example of how this could be done.
the first picture shows the widget script, for this example i made a 3 key keypad to keep it simple. ok so create a widget and add a button for each button you want on the keypad (probably 10, 0-9). next add a text component (text block). now go into the graph section and create two text type variables, comboInput and CorrectCombo. now go back to the designer and bind the text to the comboInput variable. back to the graph (enough with the back and forth right).
next we will work on the main functions script, we will begin at the end (bottom of picture) by creating the test combo event which will test if the combo entered matches the correct combo. we d othis test simply with a equal node (==) then a branch, if true then the combo is right and we do something, if false the combo is wrong and we reset the variable. the next event we will work on is the update combo event which will serve to add numbers to the variable as we enter them. here we take a input parameter and append it to the current Comboinput then we set the comboInput variable. we then test the length of the variable and if it matches the length we want then we test to see if its the right combo with the test combo event. note that i ran into some unexpected behavior with this last section where i had to set the greater than equal(>=) node to one value higher than what i testing for so 4 became 5. ok now on to the last step here, create a on click event for each of the buttons and connect to them a call update combo node as shown and make sure to set the parameter as well. oh i also noticed you asked about sounds as well, this is where you would play a sound for a button press
the second picture shows how you could setup the creation of the widget based on your requirements. i didnt test this bit but it should work. it seems a bit complex but its not too bad. do note that this is where you set the correct combo variable so you could have many of this same kind of keypad with different combos in your level.
answered Feb 10 '19 at 04:09 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here