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!
asked Dec 03 '15 at 11:26 PM in Blueprint Scripting
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.
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.
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.
Make it a great day
answered Dec 08 '15 at 10:01 PM
Rudy Q ♦♦ STAFF
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.
answered Dec 04 '15 at 06:11 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here