After having contemplated non-euclidean geometry I decided to give it a try and bring the concept into VR. I quickly identified one challenge that needed some thought: variable room sizes.
I personally have 2.5 by 2.5 meters of space in my living room. I put up some lines on the floor to estimate what the narrowest corridor would be that still felt somehow comfortable. 50cm seemed like a good compromise to me. That means I can employ a grid of 50*50cm spaces that can be filled with contents. Even when going down to 2 by 2 meters it would still mean 4 squares in each direction. That I can work with 🙂
Now, if somebody had more space, wouldn’t it be awesome if the whole world somehow adapted and actually used the additional space as well? For me, definitely a big yes. That means in turn, modelling the world is not an option. We need a parameterized description that can feed a world generator.
And the other big aspect is: what would one actually do in this environment? I am a huge fan of escape rooms and always wanted to build an engine for that. Now, combined with nested rooms, hidden pathways and labyrinths this could be an awesome fit. And if that does not work out, we can always give the player a gun and make him shoot stuff. Or imagine a real endless runner (no teleportation) where you have to constantly run to escape some danger behind you. Oh this I have to park and investigate later. Sounds very promising.
Now I just need a fresh git repo and a catchy name for it. Voila: Maze VR is born 🙂
From the 3 possible methods outlined earlier, I decided to go with corridors initially. My line of thinking was that it is the easiest and also “cheapest” in VR. And since it is all done programmatically, I can switch to other techniques rather easily later on. To get a feeling of what is doable, I cut out pieces of paper to simulate zones inside a room where the player would trigger a “room swap” without him noticing.
Each room would need to contain at least two zones, one through which you come in and one through which you leave. Both occupy space. The most space efficient way I could find was a corner transition, allowing even to go out from one side and back again into the other, allowing endless room transitions. It’s a bit boring though after a while.
I nice trick that came to my mind were elevators. Even though space is limited, in VR the vertical space is unlimited. And elevators also usually don’t cause VR sickness since it is a self-activated motion by the player. What about stairs? Would that work? A quick test with a curved staircase (created in probuilder) shows: yes and no. One can go up successfully but it just does not feel right. I will explore two other options later: slopes and escalators. I actually have a good feeling about slopes. Imagine running up a winding slope. It might just be enough to trick the brain.
Now it was time to get my hands dirty. I created a world manager class that takes the play area size as an input and some prefabs for walls and the floor and a format containing the transition zones.
Once I could place transition zones, I took a step back and reworked the data structure, giving it, the still same hierarchy as used today (once we reach that in a different blog post it probably has evolved, but hey):
- Level -> Room -> Floor -> Entities
Next I add a door, a button, an elevator and a test plain cylinder object to check if the dynamic placement is correct. Each object has it’s own scripting behaviors attached, unknown to anything else and therefore independent. The method of communication between the elements are global variables. A button can change a variable. The door can listen to variable changes and react to them. That’s the only contract needed. After a bit of tinkering, I was able to define a world like this:
In it there are two floors, an elevator that takes the player to the second floor, two buttons which open each door and two transition zones. If you walk into a transition zone, it would hide the current room and load the second room instead onto the same area, exchanging all geometry. Remind me to add a video later on (needs some time travel inside the repo).
Now, we are getting somewhere! A quick test in VR shows, this is already fun and I am hooked on the potential. Time to make the world a bit prettier with the next step.