Puzzle Mechanics – Rotating Picture Puzzle

Greetings Readers!

Welcome to another exciting edition of Chronicles of Coding: The Good, The Bad, And The Buggy. In this week’s post I will be discussing the design of one of my puzzles that involves rotating pieces of a picture to make the picture look correct using buttons to rotate rows and columns independently.

The first step to this is finding a picture and getting it split into a grid. While this first step may seem a hard to figure out how to accomplish, there are a lot of websites that will do this for you for free (with/without a donation), I used Imagy. So, that takes care of the first step.

The next step is implementing the visual interface in Unity. There are a couple different ways to do this but I made a bunch of planes, set into a grid overlaying a wall. There are 12 planes acting as buttons to rotate the pieces in-place. Each of the picture planes will use the picture pieces as a material and when all the pieces reach (0, 0, 0) for their rotation, the puzzle will be solved.

The last step is scripting the interaction, this is where I can’t decide on which option to go with. The first option is to write two scripts, one for a left rotation, and one for a right rotation. This has the advantage of easily being able to tell a button what objects it can rotate which way. They would both have variables for their controlled objects and an interact method that rotates those objects by 90o. The downside is that I could very easily make the mistake of adding the wrong objects to some button’s script. There is also the question of getting multiple objects to rotate at the same time, which could be difficult given that the method can only act on one object at a time. This could cause a domino effect instead of simultaneous movement. Another option is to write a script for each picture piece and attach that script to the rotate button. This could give me the simultaneous movement I’m after, but it would get pretty confusing having three very similar scripts attached to an object.

The third and potentially best option is to use scriptable objects. This could potentially give me the simultaneous movement I’m after and I would only need one script for each picture panel piece and one script for each button. The methods for turning would be kept within the scriptable object and the picture panel piece would be subscribed to these scriptable objects, so when the button is clicked all the panels subscribed to that scriptable object will react at the same time. Essentially, the button sends the turn signal to a scriptable object -> the object reacts to the input and sends the correct signal to turn the panel -> every panel subscribed to this object reacts at the same time and rotates. I think this is my best option.

Puzzle Mechanics can sometimes be difficult to develop but they can also be fun to think about.

Keep your eyes peeled for my next post!

The Importance of Design

Welcome back readers!

This week I’ve officially started my new team project……A 3D Escape Room Game! The theme is going to be four horseman of the apocalypse and I get to design the famine room! As most of us probably know, the first step in any new software development project is the design step, which is what this week’s blog just happens to be about.

Design can be thought of in two parts for software development:

  1. The back-end – how the software will use and store its data
  2. The front-end – what your users see and interact with

Both parts of the design need to work in harmony, especially in a video game. For this project we also have a third kind of design to worry about, puzzle design. This week we are all working on visual and puzzle design of our various rooms. So, let me talk a little about the design I’m working on.

For my famine themed room, the overall design will be a kitchen. I got the idea to use a kitchen from my lovely wife when I was stuck trying to come up with a design theme and thought that it was brilliant, so I went with it. As a side note, always listen to your significant other. The hard thing now is coming up with puzzles that use the theme. I thought of one involving a hidden safe in the freezer that gets revealed by another puzzle. The clues need to be somewhat obvious so that the player doesn’t get stuck yet hidden enough to be a challenge or it’s boring. Another puzzle I thought of involves using the decorations around the room to find specific hidden objects, but it might be a bit too cryptic. So far, this project has reinforced that video game design is kind of hard and a big balancing act.

That’s all for this week, stay tuned for my next post!