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"

How do I open a door with multiple switches?

Hi, I have a door in my level which the player needs to open, but to do so there are 8 switches lined up against a wall nearby, and only 4 specific ones need to be activated to open the door.

What needs to be done is some sort of blueprint script which recognizes when the 4 that need to be activated have been, and the 4 that shouldn't be activated haven't been.

All I've got right now is the matinee of the door opening and 8 switches which have point lights that toggle on or off when the user presses 'F' near them, I'm not really sure where I can go from here.

Any help would be appreciated, thanks in advance!

Product Version: UE 4.9
more ▼

asked Dec 03 '15 at 11:26 PM in Blueprint Scripting

avatar image

1 2 3 3

avatar image ScruffyHollywood Dec 04 '15 at 06:15 AM

So you want a combination lock? Just have a bool check on the door for the 4 that open it, or have the switches add 1 or reduce 1 to a door variable and when the doors number hits "4" it opens.

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

2 answers: sort voted first

Hello IbyGTR,

I made quick example that will get you pointed in the correct direction. I hope that this information helps.


In this picture I have created a new actor blueprint named switch and I have added two boolean variables to it. As you can see I have exposed them on spawn. This will allow you to add the switches to the level and choose which ones you would like to be needed.

alt text

Here is an example of setting the "Needed" variable for one of the switches. I did this by selecting one of the switch actors that I placed in the level.

alt text

This is a screen shot of the Door blueprint. In this blueprint I have used the get all actors of class node to find all of the switch actors in the level and I have checked to see if they are needed. If they are needed I set the "needed count" variable up by one so that I will have an accurate count of the number of needed switches. From there I check to see if the actor's "on off?" variable is true and if it is I set the "Current Count" variable up by one. This means that if the "Needed count" ever equals the "Current Count" that all of the needed switches have been turned on.

alt text

Make it a great day

more ▼

answered Dec 08 '15 at 10:01 PM

avatar image

Rudy Q ♦♦ STAFF
47.3k 545 132 525

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

One idea could be setting up booleans. The four that need to be activated to true conditions and the four that need to be off to false that then activate the matinée.

more ▼

answered Dec 04 '15 at 06:11 AM

avatar image

2.1k 59 14 128

avatar image IbyGTR Dec 05 '15 at 02:50 PM

Thanks for the answers, but how would you do this in blueprints? I've never done bools before and can't seem to find anything similar online

avatar image EyeDee10Tee Dec 05 '15 at 07:54 PM

ill make a mock up here in a min. You will need to adjust it to fit your BP setup.

avatar image EyeDee10Tee Dec 05 '15 at 08:11 PM

ok darnit well unreal isnt opening for me atm. So ill point you in the right direction. On youtube Unreal engine has a tutorial on opening a door with blueprint. I'd copy that example and make references to all 8 switches. a bool is a true or false condition. True means on and false means off. so arrange the bools in order that when the correct switches are true and the wrong switches are false it executes your matinee on the door. Hope that helps sorry i cant get you a picture to help visualize.

avatar image IbyGTR Dec 08 '15 at 05:03 PM

Hey thanks I was able to make it work, using 8 bools connected to an "and" node which triggered the door to open once they're all true, the only issue was I wasn't able to make it that it only opens when 4 are true and 4 are false, which I am still trying to figure out.

(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