# Detailed Setup

## Quick Tips & Troubleshooting

{% hint style="info" %}
**QUICK START:** You can add the **Entire\_Keypad\_DemoScene** to your scene and it will have all the keypad system setup and ready to use&#x20;
{% endhint %}

### TextMeshPro Required

{% hint style="info" %}

* Please note that TMP will appear as a popup if not installed in your project
* Click **Import TMP Essentials** to use the system fully
  {% endhint %}

### Tags Reference Guide

{% hint style="info" %}

* **Raycast:**&#x20;
  * 3D keypad / phone model should be tagged: **Keypad**
* **Trigger:**&#x20;
  * 3D keypad model should be set to: **Untagged**
  * FPSController should be tagged: **Player**
    {% endhint %}

## System Setup

### Step 1 - Player Setup

{% hint style="info" %}

1. Place the **FPSController** prefab in your scene from the **Prefabs** folder
   1. Set the **FPSController** object to the tag of **Player**
2. On the **MainCamera** – Attach **CodeDeviceInteractor** Script. (If not already).
3. CodeDeviceInteractor Settings:
   1. Set the **InteractDistance** (Default: 5)
   2. Set the **DeviceTag** (Default: CodeDevice)
   3. Set the **InputKey** (Default: E - [Uses the older input system](https://speedtutoruk.gitbook.io/keypad-system-doc/support/where-are-inputs))
      {% endhint %}

<figure><img src="https://3807630089-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX7GiPc_l1RUpLjZfGG%2Fuploads%2Fmz3kW65gt45dBXTAJqJ6%2FCodeInteractor.JPG?alt=media&#x26;token=03ad5dd7-45e2-48e3-a06c-92a86b1530fc" alt=""><figcaption></figcaption></figure>

### Step 2 -  UI Manager Setup

{% hint style="info" %}

1. Add the **UIManager** object into the hierarchy and add the following references
   {% endhint %}

|                                |                                                                    |
| ------------------------------ | ------------------------------------------------------------------ |
| Keypad Input Fields (CodeText) | Add out of the **UI - Type - InputFields** from the children below |
| Canvas References              | Add the canvas' to the correct slot                                |
| Raycast Interact Prompt        | Add the **UI - InteractPrompt** from the child below               |
| Trigger Interact Prompt        | Add the **UI**                                                     |
| Crosshair                      | Add the **UI**                                                     |
| Persist Across Scenes          | Tick this box if you want this manager to stay between scenes      |

<figure><img src="https://3807630089-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX7GiPc_l1RUpLjZfGG%2Fuploads%2FbS3jNKXk8iwVGytHhTKW%2FUIManager.JPG?alt=media&#x26;token=82cd52ff-fd61-4d37-9c3a-a3ac4012adf5" alt=""><figcaption></figcaption></figure>

#### UI Manager Objects

<figure><img src="https://3807630089-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX7GiPc_l1RUpLjZfGG%2Fuploads%2F7E7N0cioJ0i2hVriKASF%2FUIManagerObjects.JPG?alt=media&#x26;token=fe9032ab-ce3f-48c0-b7d4-8a8f81d70178" alt=""><figcaption></figcaption></figure>

### Step 3 - Keypad Audio Manager

{% hint style="info" %}

1. Add ONE **Audio Manager** to the hierarchy
2. Add the ScriptableObjects named
3. If you need more help on creating new audio ScriptableObjects:&#x20;

[adding-new-audioclips](https://speedtutoruk.gitbook.io/keypad-system-doc/managers-explained/adding-new-audioclips "mention")
{% endhint %}

<figure><img src="https://3807630089-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX7GiPc_l1RUpLjZfGG%2Fuploads%2FzIf2l897oRKTPpLm0SA6%2FKeypadAudioManager.JPG?alt=media&#x26;token=25f82363-21ef-44e7-910b-88aee2469dc8" alt=""><figcaption></figcaption></figure>

### Step 4 - Disable Manager

{% hint style="info" %}

1. Click the "**+**" on either the **OnPlayerDisabled()** or **OnPlayerEnabled()** to add new events
2. I disable the **FirstPersonController** script by selecting the **FirstPersonController > Bool Enabled**&#x20;
3. I disable the **CodeDeviceInteractor** when the player is disabled
4. I actually enable the **CodeDeviceUIManager.ShowCrosshair**
   {% endhint %}

{% content-ref url="../managers-explained/disabling-player" %}
[disabling-player](https://speedtutoruk.gitbook.io/keypad-system-doc/managers-explained/disabling-player)
{% endcontent-ref %}

<figure><img src="https://3807630089-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX7GiPc_l1RUpLjZfGG%2Fuploads%2Fz2nS6AsYutUjQlj4oXxZ%2FDisableManager.JPG?alt=media&#x26;token=a276bdf1-82c2-4eb5-b534-9ab77be3aa6a" alt=""><figcaption></figcaption></figure>

### Step 5 - Setting up 3D Keypad Model

{% hint style="info" %}

1. Open any of the Raycast or Trigger keypad collections and find the Keypad 3D model
2. Set tag: **DeviceCode** (If using for a FirstPerson setup)
3. Has the **DeviceCodeItem** script attached with the controller added to the slot
4. Has a **Box Collider**
   {% endhint %}

![](https://3807630089-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX7GiPc_l1RUpLjZfGG%2Fuploads%2F2fjhkrxoHcClY6LlCjIV%2FKeypad_Model.JPG?alt=media\&token=ce8e1e9c-3329-4c4c-a94d-6481562f8bed)

### Step 6 - Keypad / Phone Controller Setup

{% hint style="info" %}

1. Add a Keypad / Phone controller to any empty gameobject or similar
2. Take a look at the **Controller** script for that set of objects - See settings below
   {% endhint %}

<figure><img src="https://3807630089-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX7GiPc_l1RUpLjZfGG%2Fuploads%2FHsXVzfXcaGfSBoa5BJjL%2FKeypadControllerNEW.JPG?alt=media&#x26;token=c55b104b-a63e-4d62-bbaf-a729c419fb15" alt=""><figcaption></figcaption></figure>

| **Keypad Type**               | Choose: Modern, Scifi, Keyboard, Bomb                                                                                                                                                                                                         |
| ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Input Limit**               | Set character limit, based on the code you’ve just chosen                                                                                                                                                                                     |
| **Code List**                 | <ul><li>Set the array size to add more code options</li><li>Inside each option is a <strong>Codes</strong> to set the code you would like player to input</li><li>Then an event to activate when this code is input into the keypad</li></ul> |
| Closing Input                 | This is the input used to close the keypad                                                                                                                                                                                                    |
| **Keypad Interaction Sounds** | Add the ScriptableObject objects from the corresponding folder                                                                                                                                                                                |
| **Keypad Input Sounds**       | Add the ScriptableObject objects from the corresponding folder                                                                                                                                                                                |
| **Trigger Event**             | Set whether this is a trigger event version by selecting the check box, if true. You will get another option to add the trigger object                                                                                                        |

### Step 7 - Unlock Event:

{% hint style="warning" %}

* Click the **+** icon in the bottom right, it will add a new event and you can place any gameobject which may have a script with a public method you want to call.&#x20;
* In this case I have added the door object, this has a script called **DoorController** which has a public method called **OpenDoor**
* You can then run this code each time you unlock something, this can be changed on each door, and multiple events can happen in each
  {% endhint %}

{% content-ref url="../support/unlock-event" %}
[unlock-event](https://speedtutoruk.gitbook.io/keypad-system-doc/support/unlock-event)
{% endcontent-ref %}

<figure><img src="https://3807630089-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX7GiPc_l1RUpLjZfGG%2Fuploads%2FArlyw8MJjG1pPulQy5cc%2FUnlockEvent.JPG?alt=media&#x26;token=40043f98-7695-4d23-9e62-0fe9fc1908a4" alt=""><figcaption></figcaption></figure>
