Lever Puzzle Sys - Setup

Basic Steps

  1. I'd recommend adding the "LeverSystem_Objects" from the "Prefabs > Individual_Prefabs > Single Objects" section this should include a:

    1. "SwitchBox_Model" object (With Interaction_Colliders)

    2. "LeverController_1" (With power levers)

  2. "LeverController_1" should have a:

    1. "LeverSystemController" script attached

    2. Tag of "LeverController"

  3. Inside the "LeverController_1" object should be the power levers - They should have:

    1. Tag of "InteractiveObject"

    2. Layer of "Interact"

    3. Box Collider attached

    4. AKItemController script - Primary set to "Lever Sys"

    5. LeverItemController script - Set to "Lever"

    6. LeverController script

      1. Set the number to the number you want this lever to be in the sequence

      2. Set the animation name, the default is "Handle_Pull"

      3. Add the "LeverController_1" object to this slot

  4. The SwitchBoxModel > InteractionColliders

    1. TestButtonCollider & ResetButtonCollider should have:

      1. Tag "InteractiveObject"

      2. Layer "Interact"

      3. Add a "Box Collider"

      4. AKItemController set to "Lever Sys"

      5. LeverItemController set to "Test Button" and "Reset Button" respectively

      6. LeverController script with just the "LeverController_1" object adding to the bottom slot

  5. 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