One of the first goals the player will have when playing the game is to open the safe. After completing the first puzzle, the player will find the safe and can already interact with it.
Using C# I scripted several codes, the one important right now was to check what the player is looking at. As we had a highlight function when the player looks at objects it can interact with, it was important to know if the object was the safe. This allowed me to press on the numbers on the safe to test write the pin code to unlock it.
Wrote the script in C# to aid me in the safe puzzle. As the safe has a 4 digit code, there are 4 slots to place numbers on. This script checks if a slot has been used and changes a boolean.
A scriptable object takes the public booleans and makes the information accessible to the other scripts, making sure there always can only be one number per slot.
The Final Version
Since there were no artists in our team, the safe is a beautiful "art" as it's built entirely in cubes of different sizes. I learned a lot during the process and several how-to-not do things.
The safe works as intended and does it's job, when the correct pin code has been pressed, the doors open. This allows the player to progress the game to the next stage.
Please note: The gif does not show the real in game pin.
The First Puzzle
Placing the pickable objects on the correct position was not easy. It would constantly fall on the wrong location or off the table. This is due to the picking up script holding the items in front of the player in quite short range.
To make it simpler, I scripted a code to auto place the item on the table puzzle piece. If the player is holding one of the desirable objects in hand, then approach the table, the object will automatically place itself. Made it so both objects can be placed on both locations, though only one at each location at the time.
The object the player interacts with the most is the door. Scripted in C# the simple function of interacting with a door became a longer script than necessary as I continuously incorporated functions that inreality should be in separate scripts.
The doors and the script "Open" worked perfectly. We could have doors opened, closed, locked and even give the player a message if the door was not only locked but give hints that there is something behind it. Quite satisfied with the end product and smooth door animations.