# Detailed Setup

## Quick Tips & Troubleshooting

{% hint style="info" %}
**QUICK START:** You can add the **Padlock Demo Scene Prefab** to your scene to get everything setup and ready to go without having to follow any extra steps.
{% endhint %}

### Layer Setup

{% hint style="info" %}
**CREATE LAYER:** Create a Layer in the top right of the Unity Inspector called **PadlockSpinner**
{% endhint %}

### FPS Controller usage

{% hint style="info" %}
When starting your new project you'll need to use a character controller you wish - I have included my **STFPSController** for ease of use
{% endhint %}

## System Setup

### Step 1 - Check the Padlock Prefab Spinner Layer

{% hint style="info" %}

1. Open the Padlock Spawnable objects from the prefabs folder and each spinner should be setup as below
   1. Padlock Spinner Setup:
      1. Make sure to add the **PadlockNumberSelector** script – Set the row according to it’s row
      2. **Box Collider**
      3. **Rigidbody**
      4. Set the Layer to **PadlockSpinner** (Make sure to create a Layer in the top right of the inspector called PadlockSpinner)
         {% endhint %}

<figure><img src="https://2236607572-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbcA6suFQtgZxhgZbYp%2Fuploads%2FKPwnU8FOlgIEnpZRx69U%2FSpinnerSetup.JPG?alt=media&#x26;token=2e7dcce2-2a7d-4f55-9467-c0a7eb2f76ad" alt=""><figcaption></figcaption></figure>

### Step 2 - Player Setup

{% hint style="info" %}

1. Add the **FPSController** prefab from the p**refabs** folder to your scene. (You can drag this into the hierarchy or the main scene.)
   1. Set the **FPSControllers** layer to **Ignore Raycast** if you're having interaction issues with player colliders blocking the way
2. Main Camera Settings (Parented to the FPSController object)
   * Add the **PadlockInteractor** (If not already).
   * Set the tag to **MainCamera**
   * Add a **Physics Raycaster**
     * Set the **EventMask** to **PadlockSpinner**
       {% endhint %}

<figure><img src="https://2236607572-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbcA6suFQtgZxhgZbYp%2Fuploads%2F6b65AoFNizctYrS7pyCf%2FMainCaemra.JPG?alt=media&#x26;token=d22a50ca-eebf-4548-ba7d-59a3de759f55" alt=""><figcaption></figcaption></figure>

### Step 3 - Setting Up Trigger or Raycast Versions

{% hint style="info" %}

1. Add **PadlockTrigger / Padlock Raycast** sets to your hierarchy or scene from the assets Prefabs folder. Add this asset wherever you want in your scene.
   {% endhint %}

<figure><img src="https://2236607572-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbcA6suFQtgZxhgZbYp%2Fuploads%2FK3myIW50WZvZpHXT0xAV%2FRaycastpadlocks.JPG?alt=media&#x26;token=6feda9a6-6457-4e90-a8b0-207b3a50e28c" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
2\. Make sure your **Padlock Interactable** GameObject has

1. **Box Collider**
2. **PadlockItem** script - Add the controller GameObject here (See below)
   {% endhint %}

<figure><img src="https://2236607572-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbcA6suFQtgZxhgZbYp%2Fuploads%2Fa7TVnAjOhFhWNF6Qspfy%2FInteractable.JPG?alt=media&#x26;token=9daa2a5d-4506-4633-8d12-811a35d939fc" alt=""><figcaption></figcaption></figure>

### Step 4 - Padlock Controller Setup

{% hint style="info" %}

1. Select **Padlock Controller** object if not already added from the combined prefabs to your project, which will have the **PadlockController** script added
   {% endhint %}

<figure><img src="https://2236607572-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbcA6suFQtgZxhgZbYp%2Fuploads%2FVexTvu1uonniDZDGfFqM%2FPadlockController2023.JPG?alt=media&#x26;token=4e3a4b5e-2a7d-4889-8a98-7ddc4552104d" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
NOTE: Read through the information below and attach the correct GameObjects in the **PadlockController** script in the inspector. See the image on the next page for more details
{% endhint %}

| Type                                           | Description                                                                                        |
| ---------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| <p><strong>Your Combination</strong><br>  </p> | This is the code order you wish to open the padlock. 4 digits (1-9) only.                          |
| **InteractableLock**                           | Add the **Padlock\_Interactable** object to this slot                                              |
| **Prefab To Spawn**                            | This is the prefab from the spawnable prefabs folder that you wish to spawn in front of the camera |
| Distance From Camera                           | How far the padlock should spawn away from your camera                                             |
| Animation Name                                 | The animation name to play when opening the lock                                                   |
| **Audio Names**                                | The ScriptableObjects for all audio effects                                                        |
| **isPadlockTrigger**                           | Only tick this if you’re using a trigger event and have filled the above slot.                     |
| **Trigger Object**                             | Added your trigger event which would have the script **PadlockTrigger**                            |
| **Unlock Event**                               | You can add a gameobject with a script you want to activate when you get the code correct.         |

### Step 5 - Disable Manager Setup

{% hint style="info" %}

1. Drag a **DisableManager** - From the prefabs folder and you can start by adding new events for when the player should be enabled or disabled, see more inforomation on the page below.
   {% endhint %}

[disable-manager-explained](https://speedtutoruk.gitbook.io/padlock-system-doc/getting-started/disable-manager-explained "mention")

### Step 6 - Audio Manager Setup

{% hint style="info" %}
**AudioManager** - Add all of the appropriate ScriptableObject audio effects from the scriptableobjects folder
{% endhint %}

![](https://2236607572-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbcA6suFQtgZxhgZbYp%2Fuploads%2Fh58uGKdQPmKmwgmUSkFU%2FAudioManager.JPG?alt=media\&token=d42102df-482f-468e-98bc-f941b2c48b03)

### **Setup 7 - Setup UI Manager**

{% hint style="info" %}
**UIManager** - This UI manager will have the canvas for all UI elements parented and you should add the correct UI elements to the slots in the manager.
{% endhint %}

![](https://2236607572-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbcA6suFQtgZxhgZbYp%2Fuploads%2FvLI9p5uW4jCY6Gd3mScj%2FUIManager.JPG?alt=media\&token=09dd71d6-1844-4ef0-abef-85e646211663)

<figure><img src="https://2236607572-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbcA6suFQtgZxhgZbYp%2Fuploads%2FdlQqjuYQXch1R9SkogxX%2FUIItems.JPG?alt=media&#x26;token=d8c7e7a7-a93a-4071-972a-2dc6d5df9f42" alt=""><figcaption></figcaption></figure>
