I created an item inspection, just a regular one, like the one you see in horror games where the object appears in front of you and you can rotate it around. I thought it would be fun to be able to interact with that item as well. If you see something of interest on the object, like a code for a safe or something, you could write it down in the interactive book or maybe you can click several things on the object and it would be a puzzle of some sort and the box would not open and reveal the content inside until you had clicked the buttons in a specific order.
This took me down a rabbit hole because after I made a very simple click function I started to think of even more advanced puzzles I could do. I then wanted to add 3 wheels on the front of a box and be able to turn them all separately, this made everything more complex and I had to make some changes to the system. I used to do specific clicks on x amount of boxes that you could place around the item, now I was moving over to a more dynamic approach and use static meshes or collisions. The choice should be dependent on the puzzle I wanted to create and it should be easy to set up with as many clicks as I want.
This was really fun when the code was finished. To make a puzzle you do custom code in the child item. The master item contains all functions needed to know if there are puzzle components and what you can click. I created a scene component in the master item and in the child item you can add objects to that scene component. These objects are the ones you can interact with. Then you just check if you are trying to click a specific component trough the master item and you can create whatever code you want for that component upon click.
After implementing all input you can now click and click and hold with both right mouse button and left mouse button to interact with the objects. One puzzle only requires you to press buttons in a specific order, but the other puzzle requires you to turn 3 wheels and line them up. You can rotate them forward and backward.
They both check and do actions once the puzzle is solved. In this case, it just opens the box and reveals something that is inside the box. You can make it do whatever you want. I started to spin the wheels 360 before unlocking the lid, so rewarding.
Had a great time with this one.. 🙂