Hey guys,
I am relatively new to UE4 and am trying to create a blueprint script that will trigger a matinee event (in this case a door opening), when three separate switches have been pressed. I have created a blueprint that will trigger the door opening when any one of the three switches has been pressed but cannot figure out how to make it so that the door only opens when every switch has been pressed. Any help with this would be greatly appreciated as I have been unable to find any tutorials for this type of blueprint.
I would not use a level blueprint for this. I’m away from PC but here’s the concept:
- Add a variable to your Door blueprint of Matinee reference type. Make it editable. Call it DoorMatinee.
- Add a variable to your Door blueprint of Actor references array type. Editable as well. Call it AllSwitches.
- Add a variable to your Door blueprint of Boolean type. Call it bAllSwitchesAreOn, set true by default.
- Add a variable to your Door blueprint of Boolean type. Call it bIsOpen, set false by default.
- In Switch blueprint, onBeginOverlap call Enable Input and add PlayerController.
- In Switch blueprint, onEndOverlap call Disable Input and add PlayerController.
- Add a variable to your Switch blueprint of boolean type. Call it bIsOn. false by default.
- Use ‘E’ (or any other key) and adda flip-flop drag a pin from flip-flop boolean and SET your bIsON; (this is basic toggle functionality)
- In Door blueprint, on even tick, do a ForLoop on AllSwitches, cast each array item to Switch blueprint then GET the value of bIsON, use a Branch and on False, assign bAllSwitchesAreOn to false.
- Drag a pin from Completed(from for loop) and use branch, for condition use bAllSwitchesAreOn . If True - add another branch and condition to bIsOpen . If False - Play your matinee. then SET bIsOpen to true;
- Place your door on your level. Click on it, and in property assign Matinee and Switches , to appropriate actors in your level.
Hopefully you can put this to blueprints. Cheers.