Keypad Sys - Setup

Keypad System - Video Setup

Keypad Controller Main Setup

How to add a trigger event to for this system?

Basic Steps

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

    1. Keypad Controller Object

    2. Keypad Canvas Object

    3. Keypad Model Object

    4. Keypad Door Object

  2. Keypad_Controller should have a:

    1. "KeypadKeyController" script attached

    2. "KeypadController" script attached

  3. Keypad_Canvas

  4. Keypad Model should have a:

    1. "AKItemController" script attached

    2. "KeypadItemController" script attached

    3. Box Collider attached

    4. Tag of "InteractiveObject" and layer of "Interact"

  5. Door object or similar with your custom script or the "KeypadDoorController"

Keypad Objects Setup

  • I have created a basic setup for organising the system, an empty gameobject to hold all of the keypad assets:

    • Keypad_Controller

    • Keypad_Canvas

    • Keypad_Model

    • Keypad_Door

Keypad Controller Setup

This object should be an empty GameObject and it will control everything that goes on for your flashlight system!

Make sure this object has a "KeyPadKeyController" and a "KeyPadController" script with custom settings!

Keypad Parameters:

Valid Code

The string code for the player to match with their input

Character Lim

The amount of characters in your code

UI Elements:

Code Text

The InputField from the Keypad Canvas

Keypad Canvas

The entire Keypad Canvas from the associated object

Trigger Type - ONLY If using a trigger event:

Trigger Event

Add the "Padlock Trigger" which will be a gameobject you create

IsPadlockTrigger

Tick if you're using a Padlock Trigger

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 open a door, or some other object. I have added a simple example "KeyPadDoorController". See the code below:

public class KeyPadDoorController : MonoBehaviour
{
    private Animator anim;

    private void Start()
    {
        anim = GetComponent<Animator>();
    }

    public void PlayAnimation()
    {
        //This is an example of playing the "DoorOpen" animation
        anim.Play("OpenDoor", 0, 0.0f);
    }
}

Keypad Model Item Controller

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" and a Layer of "Interact"

  • Add a "Box Collider" to your object

  • Add an "AKItemController" - Set the System Type to: "KeypadSys"

  • Add a "KeypadItemController" script to the object

    • KeypadController variable: Add the connected "Keypad_Controller" object

Keypad - Canvas Setup

NOTE: This only needs to be done if you’re setting the canvas buttons yourself or if anything might be missing.

Select and open out your “KeypadCanvas” (In Hierarchy) to find all the elements.

Select any of the Button numbers, add an “OnClick()” event in the bottom right of the inspector by clicking the “+”. (Unless it already has one added, image below).

Add your “KeyPadController” object to the available slot (This will link the keycontroller script which exists on that object).

On the drop down on the right, (No function dropdown if nothing is selected) choose the “KeyController” option which will open out into more.

Choose “KeyController.KeyPressString”

You can then add whatever number or keyboard symbol you like in the slot below the dropdown. Continue this for each button available.

NOTE: Similar setup for the CLOSE / CLEAR / ENTER Button.

Select any of the input keys, add an “OnClick()” event in the bottom right of the inspector by clicking the “+”.

Add your “KeyPadController” to the available slot

On the drop down on the right, choose the “KeyController” option which will open out into more. Choose “KeyController.KeyPressClose” or “KeyController.KeyPressClr” or “KeyController.KeyPress.Ent” to the corresponding buttons.

Default Controls

  • Left Click to interact with a pickup

  • Use the "Esc" Key on each of the keypads to exit the keypad

You can change these in the "InputManager"

Last updated