Lever Puzzle Sys - Setup
Basic Steps
I'd recommend adding the "LeverSystem_Objects" from the "Prefabs > Individual_Prefabs > Single Objects" section this should include a:
"SwitchBox_Model" object (With Interaction_Colliders)
"LeverController_1" (With power levers)
"LeverController_1" should have a:
"LeverSystemController" script attached
Tag of "LeverController"
Inside the "LeverController_1" object should be the power levers - They should have:
Tag of "InteractiveObject"
Layer of "Interact"
Box Collider attached
AKItemController script - Primary set to "Lever Sys"
LeverItemController script - Set to "Lever"
LeverController script
Set the number to the number you want this lever to be in the sequence
Set the animation name, the default is "Handle_Pull"
Add the "LeverController_1" object to this slot
The SwitchBoxModel > InteractionColliders
TestButtonCollider & ResetButtonCollider should have:
Tag "InteractiveObject"
Layer "Interact"
Add a "Box Collider"
AKItemController set to "Lever Sys"
LeverItemController set to "Test Button" and "Reset Button" respectively
LeverController script with just the "LeverController_1" object adding to the bottom slot
If you're using more than one instance of this puzzle in the same scene, duplicate the entire "LeverSystem_Objects" folder to make a clone
Lever System Objects Setup
I have created a basic setup for organising the system, an empty gameobject to hold all of the lever assets:
LeverController
SwitchBox_Model
Lever Controller Setup
This object should be an empty GameObject and it will control everything that goes on for your lever system!
Make sure this object has a "LeverSystemController" script attached
In-game order (Used for debugging ONLY):
Player Order | This will be used to keep track of the lever pulled in an order, only used for visual reference when debugged or testing |
Custom Order:
Custom Order | This is the order that the code or sequence should go, based on your levers |
Pull Limit:
Pull Limit | Match this with the number of the power levers you do have in your lever controller object |
Timer before being allowed to pull the next lever:
Wait Timer | The amount of seconds to wait for the you can pull a lever after just interacting with one |
Add all of the required objects to the array:
Have a size of 7 (By default) | Add each "Power Level", "Test Button" and "Reset Button" for this set |
Control Box Switches:
Ready Switch | Add the "Ready_Switch01" from this set here |
Limit Reached Switch | Add the "LimitReached_Switch02" from this set here |
Accepted Switch | Add the "Accepted_Switch03" from this set here |
Resetting Switch | Add the "Resetting_Switch04" from this set here |
Control Unit Lights:
Ready Light | Add the "Ready_Light1" from this set here |
Limit Reached Light | Add the "LimitReached_Light2" from this set here |
Accepted Light | Add the "Accepted_Light3" from this set here |
Resetting Light | Add the "Resetting_Light1" from this set here |
Accept / Reset Buttons:
Red Button 1 | Add the "Test_Button1" from this set here |
Red Button 2 | Add the "Reset_Button2" from this set here |
Switch Object - Animation Names:
Switch On Name | Add the on switch animation name. Default: "Switch_On" |
Switch Off Name | Add the off switch animation name. Default: "Switch_Off" |
Red Button Name | Add the button push animation name. Default: "RedButton_Push" |
Audio Sounds:
Switch On Name | SwitchPull |
Switch Off Name | SwitchEcho |
Red Button Name | DoorBuzz |
Unlock Events:
You can use the "+" icon to add an event for when you get the correct code, you can add custom interactions if you create a new script with a public method to spawn objects, or some other type of interaction when the combination for the levers is complete.
Power Lever Setup
Add this script to a 3D Keypad model from the prefabs or one you may have created yourself
Make sure your object has a tag of "InteractiveObject"
Layer of "Interact"
Add a "Box Collider" to your object
Add an "AKItemController" - Set the System Type to: "Lever Sys"
Add a "LeverItemController" script to the object - Set to "Lever"
Add a "LeverController" script
Set the number of the lever in the script for your order
Add the name of your animation for the lever pulling (Default is "Handle_Pull")
In the "LeverSystemController" slot - Add the "LeverController_1" to this slot
Test & Reset Buttons
Do the same as above but set the "ObjectType" in the "LeverItemController" script to either "Test Button" or "Reset Button" depending on the button you want to add!
Default Controls
Left Click to interact with the levers or switches
You can change these in the "InputManager"
Last updated