> For the complete documentation index, see [llms.txt](https://speedtutoruk.gitbook.io/adventure-puzzle-kit-doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://speedtutoruk.gitbook.io/adventure-puzzle-kit-doc/getting-started/ak-item-setups/keypad-sys-setup.md).

# Keypad Sys - Setup

## Keypad System - Video Setup

{% embed url="<https://youtu.be/ytfNoI7nTic>" %}

## Keypad Controller Main Setup

{% hint style="warning" %}
How to add a trigger event to for this system?
{% endhint %}

{% content-ref url="/pages/-MB9giTZuVPnpZlpWP4w" %}
[Broken mention](broken://pages/-MB9giTZuVPnpZlpWP4w)
{% endcontent-ref %}

## Basic Steps

{% hint style="info" %}

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&#x20;
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**"
   {% endhint %}

## Keypad Objects Setup

{% hint style="warning" %}

* 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
    {% endhint %}

![](https://1990716438-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MB9gFa1PG62oL0UGY7U%2F-MD-wLfaq1fjtKg5uaQM%2F-MD0U0GqzDMomBomGFuJ%2FKeypad_Object.jpg?alt=media\&token=cbaf5e23-e1af-48ff-8737-caa4c8a78733)

## Keypad Controller Setup

{% hint style="info" %}
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!
{% endhint %}

![](https://1990716438-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MB9gFa1PG62oL0UGY7U%2F-MD-wLfaq1fjtKg5uaQM%2F-MD0U9fWDOYOkacRsIWF%2FKeypadController.jpg?alt=media\&token=e413fe2b-7ff9-4dc2-ae16-ca6c0a3c1db8)

#### 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:

{% hint style="info" %}
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:
{% endhint %}

```csharp
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

{% hint style="info" %}
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
    {% endhint %}

![](https://1990716438-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MB9gFa1PG62oL0UGY7U%2F-MD-wLfaq1fjtKg5uaQM%2F-MD0UH2DunorsTgWKWQL%2FKeypad_Model_ItemController.jpg?alt=media\&token=9d9d2c50-2d30-4766-9e66-e963663e394b)

## Keypad - Canvas Setup

{% hint style="warning" %}

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

{% hint style="info" %}
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.
{% endhint %}

![](https://1990716438-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MB9gFa1PG62oL0UGY7U%2F-MD0XyvxzDilo_E-Pbif%2F-MD0Ys-xTbNUYupGJTQX%2FKeypad_Canvas.jpg?alt=media\&token=6808978f-5e9c-4213-b69c-e181eab2044a)

{% hint style="info" %}

NOTE: Similar setup for the CLOSE / CLEAR / ENTER Button.
{% endhint %}

{% hint style="info" %}
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.
{% endhint %}

![](https://1990716438-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MB9gFa1PG62oL0UGY7U%2F-MD0XyvxzDilo_E-Pbif%2F-MD0Yb9Rqi9r9s3wL3ey%2FKeypad_Key_Setup%20\(2\).jpg?alt=media\&token=190fc8fa-accd-4bab-96e0-baf4d980ab36)

## Default Controls

{% hint style="info" %}

* **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**"
{% endhint %}
