WEBVTT
Kind: captions
Language: en

00:00:00.280 --> 00:00:03.760
I’ve always been fascinated by the&nbsp;
impossible worlds of Monument Valley,&nbsp;&nbsp;

00:00:03.760 --> 00:00:08.560
so I decided to dive in and figure out how&nbsp;
these perspective puzzles work. I ended up&nbsp;&nbsp;

00:00:08.560 --> 00:00:13.480
creating a clone of the game and designing my&nbsp;
own level. This is what I learned in the process.&nbsp;

00:00:13.480 --> 00:00:17.720
To make it all work, we need to understand&nbsp;
two main concepts: how to create the optical&nbsp;&nbsp;

00:00:17.720 --> 00:00:23.200
illusions—the impossible architectures—and how to&nbsp;
build everything else around this unusual world,&nbsp;&nbsp;

00:00:23.200 --> 00:00:26.239
like making the character navigate&nbsp;
through impossible geometries.&nbsp;

00:00:27.240 --> 00:00:31.880
Let’s dive into the first piece of the&nbsp;
puzzle: creating these impossible shapes.&nbsp;

00:00:31.880 --> 00:00:35.640
At the heart of Monument Valley’s&nbsp;
surreal spaces lies the concept of&nbsp;&nbsp;

00:00:35.640 --> 00:00:39.920
depth perception—and how to trick it.
In the real world, illusions like these&nbsp;&nbsp;

00:00:39.920 --> 00:00:44.000
are hard to pull off because our brains&nbsp;
are wired to interpret depth in three&nbsp;&nbsp;

00:00:44.000 --> 00:00:48.640
dimensions. Sculptures like that of&nbsp;
the Penrose Triangle—this strange,&nbsp;&nbsp;

00:00:48.640 --> 00:00:54.800
looping shape—only kind of work from specific&nbsp;
angles. Even then, they rely on tricks like&nbsp;&nbsp;

00:00:54.800 --> 00:01:00.000
carefully painted shadows to sell the illusion.
But video games offer a unique advantage:&nbsp;&nbsp;

00:01:00.000 --> 00:01:03.600
everything you see on screen is already&nbsp;
a flattened version of 3D space into two&nbsp;&nbsp;

00:01:03.600 --> 00:01:08.400
dimensions. This lets us cheat reality&nbsp;
in ways that wouldn’t work otherwise.&nbsp;

00:01:08.400 --> 00:01:14.240
The key here is to use an orthographic camera.&nbsp;
These ignore depth entirely and keep objects the&nbsp;&nbsp;

00:01:14.240 --> 00:01:19.680
same size on screen, no matter how close or far&nbsp;
they are. Unlike more typical perspective cameras,&nbsp;&nbsp;

00:01:19.680 --> 00:01:24.200
which mimic how our eyes see the world and make&nbsp;
objects appear smaller as they get farther away,&nbsp;&nbsp;

00:01:24.200 --> 00:01:29.920
orthographic cameras maintain a consistent scale.
This property is crucial. It lets us position&nbsp;&nbsp;

00:01:29.920 --> 00:01:35.440
objects in 3D space without worrying about their&nbsp;
actual physical layout. Instead, we focus on how&nbsp;&nbsp;

00:01:35.440 --> 00:01:40.200
they appear from the camera’s viewpoint. If&nbsp;
positioned strategically, disconnected shapes&nbsp;&nbsp;

00:01:40.200 --> 00:01:43.840
can look perfectly aligned—even if they’re&nbsp;
far apart in reality.

00:01:43.840 --> 00:01:47.650
Move the camera, though,&nbsp;and the illusion immediately falls apart.

00:01:48.826 --> 00:01:53.228
When working with simple cubes—the building&nbsp;blocks of Monument Valley levels—

00:01:53.228 --> 00:01:57.280
certain faces&nbsp;can end up misaligned, breaking the illusion.&nbsp;

00:01:57.280 --> 00:02:02.040
One solution to this problem is introducing&nbsp;
geometry patches—small shapes added in just the&nbsp;&nbsp;

00:02:02.040 --> 00:02:07.040
right spots to complete the effect. These patches&nbsp;
are designed to work from the camera’s viewpoint,&nbsp;&nbsp;

00:02:07.040 --> 00:02:11.160
seamlessly blending distant shapes so&nbsp;
everything looks perfect to the player.&nbsp;

00:02:11.160 --> 00:02:16.800
We’ve created the illusion of impossible geometry,&nbsp;
using perspective tricks and tiny hacks. But once&nbsp;&nbsp;

00:02:16.800 --> 00:02:22.040
we add a character, a new challenge appears.
Remember, while everything seems aligned from&nbsp;&nbsp;

00:02:22.040 --> 00:02:27.200
the player’s perspective, the level pieces are&nbsp;
actually at different depths in 3D space. Some&nbsp;&nbsp;

00:02:27.200 --> 00:02:31.680
platforms could be closer to the camera than the&nbsp;
character, so when the character walks over them,&nbsp;&nbsp;

00:02:31.680 --> 00:02:36.200
it might accidentally render behind&nbsp;
the platform, breaking the illusion.&nbsp;

00:02:36.200 --> 00:02:40.680
The way we use depth is crucial for building&nbsp;
our impossible levels, so we need a solution&nbsp;&nbsp;

00:02:40.680 --> 00:02:45.040
that doesn’t mess with the geometry. An&nbsp;
interesting way to handle this is by having&nbsp;&nbsp;

00:02:45.040 --> 00:02:50.600
multiple render passes—which can be achieved&nbsp;
through camera stacking in Unity, for example.&nbsp;

00:02:50.600 --> 00:02:54.360
This lets us separate the rendering of the&nbsp;
level and the character, so we can control&nbsp;&nbsp;

00:02:54.360 --> 00:02:58.240
their layering. That way, the character&nbsp;
will always appear on top of the platforms,&nbsp;&nbsp;

00:02:58.240 --> 00:03:01.680
no matter the depth of these.
Sometimes, though, we need the&nbsp;&nbsp;

00:03:01.680 --> 00:03:06.880
character to pass behind certain elements, like&nbsp;
a column. Without going into too much detail,&nbsp;&nbsp;

00:03:06.880 --> 00:03:11.560
this is relatively easy to manage by adding more&nbsp;
render layers, dividing the level into parts that&nbsp;&nbsp;

00:03:11.560 --> 00:03:17.000
are either behind or on top of the character,&nbsp;
giving us more control over the depth perception.&nbsp;

00:03:17.000 --> 00:03:19.840
Now that we know the tricks to build these&nbsp;
impossible worlds,

00:03:19.840 --> 00:03:22.006
the next step is to make&nbsp;&nbsp;them interactive. &nbsp;&nbsp;

00:03:22.720 --> 00:03:24.760
We want the player to&nbsp;
guide the character through the level,

00:03:24.760 --> 00:03:29.040
choosing a destination, and watching them walk&nbsp;
there. But how can we make the character move&nbsp;&nbsp;

00:03:29.040 --> 00:03:34.480
across this fragmented geometry? And how do we&nbsp;
calculate the optimal path to the destination?&nbsp;

00:03:34.480 --> 00:03:40.000
We need to develop a custom pathfinding system&nbsp;
tailored to this unique environment. Fortunately,&nbsp;&nbsp;

00:03:40.000 --> 00:03:44.560
it’s not as complicated as it sounds.
We can think of the level as a graph,&nbsp;&nbsp;

00:03:44.560 --> 00:03:48.880
where each small cube—the building blocks of&nbsp;
the platforms—becomes a node. These are the&nbsp;&nbsp;

00:03:48.880 --> 00:03:53.880
points the character can stop at. If two cubes&nbsp;
are adjacent from the player’s perspective,&nbsp;&nbsp;

00:03:53.880 --> 00:03:58.920
we create an edge between their corresponding&nbsp;
nodes. These edges need to be manually configured&nbsp;&nbsp;

00:03:58.920 --> 00:04:04.880
based on the camera’s viewpoint, linking nodes&nbsp;
that might not be physically adjacent in 3D space.&nbsp;

00:04:04.880 --> 00:04:09.280
When the player selects a destination, the game&nbsp;
calculates the shortest path by traversing the&nbsp;&nbsp;

00:04:09.280 --> 00:04:13.960
graph. Any algorithm capable of finding&nbsp;
the shortest path in a graph works here.&nbsp;&nbsp;

00:04:13.960 --> 00:04:19.680
I’m using a very simple one called Breadth-First&nbsp;
Search (or BFS), which systematically explores&nbsp;&nbsp;

00:04:19.680 --> 00:04:25.200
all possible paths to find the optimal route.
Once the path is determined, the character moves&nbsp;&nbsp;

00:04:25.200 --> 00:04:30.600
along it, traveling from one node in the graph&nbsp;
to another. Thanks to the strategically placed&nbsp;&nbsp;

00:04:30.600 --> 00:04:35.840
orthographic camera, any unusual behavior—like&nbsp;
the character floating or teleporting between&nbsp;&nbsp;

00:04:35.840 --> 00:04:41.040
disconnected nodes—is completely imperceptible&nbsp;
to the player, making the movement feel natural&nbsp;&nbsp;

00:04:41.040 --> 00:04:46.480
despite the fragmented geometry.
There’s one subtle challenge, though:&nbsp;&nbsp;

00:04:46.480 --> 00:04:50.480
the actual distance between nodes&nbsp;
in 3D space can vary significantly,&nbsp;&nbsp;

00:04:50.480 --> 00:04:56.360
even if they look evenly spaced from the camera's&nbsp;
perspective. To ensure consistency, the time&nbsp;&nbsp;

00:04:56.360 --> 00:05:01.720
it takes to travel between nodes must remain&nbsp;
uniform. This means the character’s movement&nbsp;&nbsp;

00:05:01.720 --> 00:05:08.080
speed needs to adjust dynamically, ensuring that&nbsp;
the timing feels smooth and steady for the player.&nbsp;

00:05:08.080 --> 00:05:14.120
And there’s one more layer to this system:&nbsp;
the graph isn’t fixed. When the architecture&nbsp;&nbsp;

00:05:14.120 --> 00:05:19.800
changes—like with rotating or moving platforms—the&nbsp;
connections between nodes must update dynamically&nbsp;&nbsp;

00:05:19.800 --> 00:05:24.920
to reflect the new configuration. This ensures the&nbsp;
character only moves when there’s a valid path,&nbsp;&nbsp;

00:05:24.920 --> 00:05:29.520
as seen from the player’s perspective.
These updates happen in real time,&nbsp;&nbsp;

00:05:29.520 --> 00:05:34.640
but they’re not automatic. During development,&nbsp;
the level designer preconfigures the routes,&nbsp;&nbsp;

00:05:34.640 --> 00:05:39.360
manually defining which edges should activate or&nbsp;
deactivate based on specific interactions—like&nbsp;&nbsp;

00:05:39.360 --> 00:05:44.160
rotating a platform to a precise angle or&nbsp;
pressing a button to open a door. By carefully&nbsp;&nbsp;

00:05:44.160 --> 00:05:50.680
setting these rules, we create an impossibly&nbsp;
interconnected world that feels alive and dynamic.&nbsp;

00:05:50.680 --> 00:05:55.883
By now, you might feel like building a game like&nbsp;
this isn’t as complicated as it seems at first.&nbsp;&nbsp;

00:05:56.480 --> 00:06:01.280
Once you understand the fundamentals—like using&nbsp;
perspective to create impossible architecture&nbsp;&nbsp;

00:06:01.280 --> 00:06:06.160
or how to develop a custom pathfinding&nbsp;
system—the process starts to make sense.&nbsp;

00:06:06.160 --> 00:06:11.200
In my experience, though, the real challenge&nbsp;
is in designing the levels. Making them feel&nbsp;&nbsp;

00:06:11.200 --> 00:06:17.280
cohesive while maintaining their mind-bending&nbsp;
nature requires both precision and creativity.&nbsp;

00:06:17.280 --> 00:06:21.720
Perspective tricks can quickly become&nbsp;
overwhelming, so every element needs&nbsp;&nbsp;

00:06:21.720 --> 00:06:26.280
careful planning and involves a lot of&nbsp;
trial and error to preserve the illusion.&nbsp;

00:06:26.280 --> 00:06:31.200
Even imagining these levels is no&nbsp;
easy task. After countless iterations,&nbsp;&nbsp;

00:06:31.200 --> 00:06:36.200
I finally created a level I’m proud of. It’s&nbsp;
far from perfect, but I think it captures&nbsp;&nbsp;

00:06:36.200 --> 00:06:41.480
the spirit of impossible architecture, and I&nbsp;
hope it inspires you to try something similar.&nbsp;

00:06:41.480 --> 00:06:45.400
If you’re curious, there’s some documentation&nbsp;
online about how Monument Valley was actually&nbsp;&nbsp;

00:06:45.400 --> 00:06:49.320
built. While I can’t say for certain that&nbsp;
my implementation matches the original,&nbsp;&nbsp;

00:06:49.320 --> 00:06:54.120
it seems to follow the same core ideas, at least&nbsp;
in theory. I’ll link some useful resources in the&nbsp;&nbsp;

00:06:54.120 --> 00:06:58.080
video description if you’d like to dive deeper.
If you have any questions or suggestions,&nbsp;&nbsp;

00:06:58.080 --> 00:07:00.240
you are welcome to join the&nbsp;
discussion on Discord or in the&nbsp;&nbsp;

00:07:00.240 --> 00:07:06.000
comments below. I’d love to hear your thoughts.
I hope you enjoyed, and see you next time.

