Lockpicking Mechcanic Recreation
Lockpicking Mechanic from Fallout 4 recreated in Unity
Move the mouse to rotate the bobby pin into place. Press and hold W on the keyboard to attempt to pick the lock. The closer the lock goes to being fully horizontal, the closer it is to being unlocked.
Hold W too long and the bobby pin will break. Unlocking will generate a new lock and an additional attempt can be made.
See the credits section below for the links, but essentially the script from Zeppelin Games defines a range in degrees from the center of the lockpick's local position and allows the lockpick to be rotated along that axis. A rotation in degrees from the center of that range is generated for each new lock and is tested against the rotation angle of the lockpick when attempting to unlock.
In addition to this core logic, I implemented some animations, sound effects, and managers to handle the possibility of different lock difficulties and the other gameplay designs that come along with that.
How It's Set Up:
I do not doubt that there are better ways of achieving this, but as this was mainly a project about further learning, I'll leave any refactoring up to you.
The lockpicking script is attached to the bobby pin gameobject, which is a child of the inner lock object. There is an additional bobbypin object that is used to animate, since the animator has control of the transform until Update() is completed. You could do this in LateUpdate(), but having a separate object to animate was how I chose to go about it.
Anyway, the script needs references to the lockpicking camera, the inner lock gameobject, the lockfollow empty gameobject (the pivot point of the bobbypin), the Animator attached to the lock gameobject, two Audio Sources, and some audio clips. The rest are simple variables, but I recommend leaving them where they are.
The camera is needed to find where the mouse is relative to the screenspace and the lockpick.
The inner lock is needed to be able to rotate the lock (and its children).
The lockfollow empty lets us set local position on the lockpick and keep track of where that point in space is when the lock is turned, since it is itself a child of the inner lock.
We have two audio sources so that one can be set to loop, and 7 audio clips, one for unlocking, one for the looping wiggle sound, one for breaking the pick, and 4 for when the bobby pin is being moved.
This script makes calls to the managers mainly for UI purposes, but also for handling lock difficulty.
Screenshots:
Credits:
- The logic that calculates position and rotation angles for the lockpick and inner lock is from a Zeppelin Games tutorial on YouTube.
- I found the code that enqueues console logs for printing to a UI element from derHugo on this StackOverflow question.
- The unlock and movement sound effects were spliced from an audio clip by Breviceps on freesound.org, licensed under CC 0.
- The sound effect that plays when a pick is broken is from an audio clip by duncanlewismackinnon on freesound.org, licensed under CC BY 3.0.
- The managers are based on the work from Joseph Hocking's Unity In Action Third Edition.
You can find the project files on my github repository.
Code from FalloutLockPicking © 2024 by Evan Kurtz is licensed under GNU GPLv3.0
Assets from FalloutLockPicking © 2024 by Evan Kurtz is licensed under CC BY-SA 4.0
Status | Released |
Platforms | HTML5, Windows, macOS, Linux |
Release date | Feb 16, 2024 |
Author | Evan Kurtz |
Genre | Puzzle |
Made with | Blender, Unity, Substance Painter & designer |
Tags | fallout, lock-picking, lockpicking, mechanic, minigames, Open Source, recreation, Unity |
Code license | GNU General Public License v3.0 (GPL) |
Asset license | Creative Commons Attribution_ShareAlike v4.0 International |
Average session | A few seconds |
Languages | English |
Inputs | Keyboard, Mouse |
Links | Blog |
Download
Install instructions
You can import the unitypackage or download the repository from my GitHub and load it from disk in the Unity Hub.
(The repository has all the scenes, including the ones I used during development. The unitypackage just has all the necessary stuff for the build proper.)
Development log
- Update 1.254 days ago
- Update 1.154 days ago
- Update 1.0cFeb 27, 2024
- Standalone Demo 1.0b!Feb 22, 2024
- Progress Report 2/13Feb 13, 2024
- Preparing the demoFeb 06, 2024
Comments
Log in with itch.io to leave a comment.
This is great. Absolutely love the fully fleshed out mechanic. Nice job
Wow thanks! That means a lot coming from you! Thanks for the tutorial! It really helped me wrap my head around how this mechanic worked