Padlock Sys - Setup

Padlock System - Setup Video

Padlock Controller Main Setup

How to add a trigger event to for this system?

Basic Steps

  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"

      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

Padlock Objects Setup

Main Camera Setup Example

  • 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

Padlock World Objects Example

  1. Padlock_Interactable_A2: This is a PBR 3D Padlock

  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)

Padlock Controller Setup

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

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:

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:

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

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"

Padlock Spinner / Combination Setup

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"

  • Add an "SpinnerScript"

    • "PadlockController Variable": Add the "Padlock_Controller" object to each of the spinners

    • Set the row of each spinner. Row 1 - 4.

Default Controls

  • 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"

Last updated