x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Connecting a Keypad to unlock a door

Hi, so I am currently making a level in UE4 (4.8.3) and have added in a asset for a Keypad (bought on the Marketplace)and of course a door w/ its own animation (from another free content pack, Shooter Level )

Now I'm struggling to connect these together so that the door will only open when the right key code is entered and access is granted, where and how do I do this?

At the moment I can enter the right keycode and it displays that it is correct/incorrect, but the door still opens when I approach it no matter what(due to its own trigger box, there no collision with the door either, but that's a later issue)

Any help?

Product Version: UE 4.8
Tags:
more ▼

asked Feb 25 '16 at 10:27 PM in Blueprint Scripting

avatar image

SCB360
1 2 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hello SCB360,

I'm assuming that you have it set up so that when the player overlaps the trigger box for the door, it opens. If this is the case, you could do this with the use of a boolean variable.

First, create the boolean variable inside of the door's blueprint and set the "Editable" setting on it to true. Make the default value of the boolean False.

Next, open the blueprint for your Keypad, return to the level editor and select the instance of your door in the level. After it is selected, go back into the blueprint for the keypad and right-click in the Event graph. It'll give you the option to get a reference to that door instance from the level.

After this, go to the logic where you have the keypad's sequence set up and on the part where the sequence is correct, have it also set that boolean to True. You can do this by dragging off of the Door reference and making a "Set booleannamehere" node.

Lastly, go back to your Door's blueprint and add a branch between the overlap event and the logic to open the door that checks the value of the boolean. If it is set to true, open the door. If it's set to false, do nothing.

Hope this helps!

more ▼

answered Feb 25 '16 at 10:57 PM

avatar image SCB360 Feb 26 '16 at 09:27 AM

OK, I followed it through step by step and the issue I'm getting is where I have to get a reference to the door in the keypad BP, for whatever reason it will not do it unless 'Context Sensitive' is unchecked, when I bypass that, the Boolean I set insists on a target and the get reference for the door will not connect at all

avatar image Matthew J Feb 26 '16 at 01:24 PM

Ah I probably should've tried this myself to be sure before telling you. Directly referencing it like that in the blueprint won't work the way I said it would. Instead, create a variable in the Keypad's blueprint and set its type to your Door's blueprint. You can then use that variable to do all of your referencing. Also, be sure to select the Keypad instance in your level and then from the details panel set that new variable to the particular instance of the door in your level so it knows what to reference.

avatar image SCB360 Feb 26 '16 at 03:28 PM

So I managed to create that reference and get it all set up, now the problem is that the door doesn't open at all, so I know something is working, but now doesn't open...

avatar image Matthew J Feb 26 '16 at 03:43 PM

This would be the time for some debugging. Try separating the windows so that you can see your blueprints (The Keypad would probably be the best to look at in this case) and your game at the same time. Press play and then at the top of the blueprint look for "Debug Filter" and a dropdown. Select the instance of the Keypad in the level if it hasn't already been selected. Then return to your game and enter the sequence. Keep an eye on the blueprint and watch what is being executed. Is the boolean ever getting set correctly when you finish entering the correct sequence? Does it ever get set back to False?

avatar image SCB360 Feb 26 '16 at 10:08 PM

According to the debugging, its going through it all just fine (and to be fair it is doing the right thing for the code being entered) but it does the same no matter if the keycode is right or wrong, hell I tried to Destroy a actor (thinking of using a forcefield instead) and even that would not work either

avatar image Matthew J Feb 29 '16 at 01:09 PM

Could you take a screenshot of the event graph where the keypad logic is happening? It could be an issue with the way it's set up.

avatar image SCB360 Feb 29 '16 at 02:02 PM

So here is the BP for the Keypad and the third image is the Door BP itself

alt text

alt text

alt text

keypad1.png (522.8 kB)
keypad2.png (497.7 kB)
door.png (309.0 kB)
avatar image Matthew J Feb 29 '16 at 02:24 PM

Thank you for the screenshots but I don't see any mention of using the boolean which I'm guessing is "Last_door_unlock". Is it just not shown in these screenshots or is it not set up at the moment?

avatar image SCB360 Feb 29 '16 at 02:38 PM

I've reset it back to what they were, last_door_unlock was the Boolean I was using

avatar image Matthew J Feb 29 '16 at 02:47 PM

With the current set up, there is no communication of any sort between the Keypad and the Door. As it stands, if the keypad is interacted with and the sequence is correct or incorrect or if the player ignores it entirely, the OnComponentBeginOverlap will be triggered once the overlap begins. Something needs to be between the OnComponentBeginOverlap (and the End overlap most likely) and the Timeline node that will cause it to only be triggered if the keypad sequence is entered correctly. You could use a Branch that checks the status of Last_door_unlock to do this. As far as setting it, you could set it to True just after your "Set" function for setting Local Int to 1. Once again, be sure that it is set to False by default or it'll just always be true anyway and we'll have the same problem.

avatar image SCB360 Feb 29 '16 at 03:09 PM

So I have set the branches here to true, no where in the Keypad BP do I put anything? To connect them?

alt text

door.png (303.2 kB)
avatar image Matthew J Feb 29 '16 at 03:21 PM

As I mentioned, you'll need to set that boolean to true from inside your Keypad BP at some point in the logic after the correct sequence has been entered. This will let the door open after the correct sequence has been entered.

It doesn't seem like you have a reference for your door inside of your KeypadTrigger BP. You'll need to add this so you can get a reference. Add a new variable and then change the type to Last_door. You can then set the reference from inside of the level editor by selecting the instance of the KeypadTrigger in the level and finding it in the Details panel. You can use this reference to set the Boolean.

avatar image SCB360 Feb 29 '16 at 03:18 PM

So here's where I've tried to add it to the keypad:

alt text

door2.png (370.0 kB)
avatar image Matthew J Feb 29 '16 at 03:45 PM

Be sure to check the checkbox in that set node for the boolean so that it sets it to true.

avatar image Matthew J Mar 04 '16 at 06:33 PM

Hello SCB360,

Were you able to figure out how to fix this problem? I would be happy to assist you further if you need me to.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question