> 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/padlock-sys-setup.md).

# Padlock Sys - Setup

## Padlock System - Setup Video

{% embed url="<https://www.youtube.com/watch?v=oflNfMYjNtI&feature=emb_title>" %}

## Padlock 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. Make sure the main camera has an empty GameObject called "**Padlocks**" which you will add the "**Mechanism**" locks to, if not already attached.
2. Add the "**Padlock Objects**" to the scene, which will have:
   1. "**Padlock\_Interactable**" which needs:
      1. A tag of "**InteractiveObjects**"&#x20;
      2. A layer of "**Interact**"
      3. Add a "**Box Collider**"
      4. Add a "**AKItemController**" script
      5. Add a "**PadlockItemController**" script and add the "Padlock\_Controller" object to the slot (As below)
   2. Padlock\_Controller needs a padlock controller script: "**PadlockController**"
      1. See setup details below
   3. Door object or similar with your custom script or the "**DoorAnimationScript**"
      1. See example setup details below
         {% endhint %}

## Padlock Objects Setup

#### Main Camera Setup Example

{% hint style="warning" %}

* The Main Camera has an Empty GameObject called "**Padlocks**"
  * Then 4 different padlocks each with separate features
    * **LockMechanism** - Is the Latch with the animation when the lock opens
    * **PadlockCombination** - The Spinners with the "**SpinnerScript**" attached
      {% endhint %}

![Padlocks on the main camera (Deactivated by Default) ](https://1990716438-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MB9gFa1PG62oL0UGY7U%2F-MD-patwsk3bS_a-FgzD%2F-MD-q-u0pjTc4jnuzb-2%2FPadlockMainCamera.jpg?alt=media\&token=b3d1a945-de36-44e5-818e-bdee435f4ced)

#### Padlock World Objects Example

{% hint style="warning" %}

1. **Padlock\_Interactable\_A2**: This is a PBR 3D Padlock&#x20;
2. **Padlock\_Controller\_A2**: Empty GameObject with the Padlock Controller script
3. **Door\_A1**: The door object you want to open
4. **FrameComponent**: Some additional 3D assets (NOT REQUIRED)
   {% endhint %}

![The padlock objects that exist in the game world](https://1990716438-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MB9gFa1PG62oL0UGY7U%2F-MD-hmoQxGtuUkYjbmbD%2F-MD-izh-BFsVJDxM09CY%2FPadlock_GameObjects.jpg?alt=media\&token=05555de1-fcaf-4477-9737-6b9a44bd1a25)

## Padlock Controller Setup

{% hint style="info" %}
This object should be an empty GameObject and it will control everything that goes on for your flashlight system!
{% endhint %}

![](https://1990716438-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MB9gFa1PG62oL0UGY7U%2F-MD-hmoQxGtuUkYjbmbD%2F-MD-ia-PF98QtEreFVcq%2FPadlockController.jpg?alt=media\&token=b9d5ba29-2f92-4990-b194-91652ffd59c1)

#### Combination and Camera Padlock References:

| Your Combination | The 4 number combination to unlock the padlock                                       |
| ---------------- | ------------------------------------------------------------------------------------ |
| Camera Padlock   | Add the "**Padlock\_Camera\_Mechanism\_A1**" from the padlock attached to the camera |
| Lock Anim        | Add the "**LockMechanism\_A1**" from the "Padlock\_Mechanism" attached to the camera |

#### World Objects:

| Interactable Lock | Add the "**Padlock\_Interactable\_A2**" or similar 3D object which is the world 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 "**PadlockDoorAnimation".** See the code below:
{% endhint %}

```csharp
public class PadlockDoorAnimation : MonoBehaviour
{
    private Animator anim;

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

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

## Padlock Interactable Item Controller

{% hint style="info" %}
Add this script to either a PBR 3D Padlock that you will interact with

* 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: "**PadlockSys**"
* Add a "**PadlockItemController**" script to the object
  * Padlock Controller variable: Add the connected "**Padlock\_Controller**"
    {% endhint %}

![](https://1990716438-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MB9gFa1PG62oL0UGY7U%2F-MD-hmoQxGtuUkYjbmbD%2F-MD-m9PwfRg6fIzp5KAW%2FPadlockInteractable.jpg?alt=media\&token=d0a1a4df-2dd1-40ce-8c23-d6aaa609675c)

## Padlock Spinner / Combination Setup

{% hint style="info" %}
Add this script to a Padlock spinner that is on the padlock within the main camera.

* Add a "**Box Collider**" to your object
* Make sure this object has a "**Rigidbody**"&#x20;
* Add an "**SpinnerScript**"
  * "**PadlockController Variable**": Add the "**Padlock\_Controller**" object to each of the spinners
  * Set the row of each spinner. Row 1 - 4.
    {% endhint %}

![](https://1990716438-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MB9gFa1PG62oL0UGY7U%2F-MD-hmoQxGtuUkYjbmbD%2F-MD-mkYyhdKyMEGq78Kw%2FPadlock_SpinnerScript.jpg?alt=media\&token=1a9e2974-26b2-46e5-8a90-32670854f428)

## Default Controls

{% hint style="info" %}

* **Left Click** to interact with a pickup
* **Right Click** to drop the padlock
* **Left Click** to interact with the spinners (When Interacting)

These can be edited in the "**InputManager**"
{% endhint %}
