A Glass Darkly

A Glass Darkly is a VR Horror game where you explore and abandoned hotel to try and find a way out. Lurking about is a monster, that if you lay your eyes upon it, will kill you. To your help, you have a mirror to avoid looking directly upon the monster, and it can help you navigate the area.

Platform:
Engine:
Language:
Production Time:
Team Size:

PC – Oculus Touch
Unreal Engine 4
Blueprints
4 Weeks
4 Designers & 7 Artists

RESPONSIBILITIES

During the game project, I was a Scripter. My main scripting responsibilities were:

I also worked on other Additional tasks, such as the monster visibility, rotation, UI- and animation implementation. Post-Mortem of the project can be found at the bottom of the page.

Grabbing System
GRABBING

We wanted grabbing and picking up objects to feel real and responsive. It was also important that it would be easy to do. Otherwise players could get frustrated in the more intense and scary parts of the game. One fundamental problem with VR though is that there is no way to stop the players hand from moving through obstacles. This means that the player could take items through walls or drop them inside other objects.

To prevent this, I used Unreals physics engine for grabbing. Using their physics handles, the objects would smoothly follow the players hands, and still detect collision. Then to stop it from behaving weirdly if you try to push it through the wall, a ray is cast between the hand and the object when the object is to far away. If the ray hits anything, the item is automatically dropped from the hand.

Doors & Drawers

Doors & Drawers also use physics handles, but can only be grabbed within a certain region. Their movement is then restricted using physic constraints, which limits their linear and angular movement. 

As they have physics, to prevent them from being pushed open with objects, their physics are turned off while they are not grabbed. This makes them also stop moving immediately as you release them. To make it feel better, they keep their physics after you release them, until their velocity gets low enough.

Mirror Functionality
Mirror

The Mirror is the players most important tool, and is used for navigating the areas, solving puzzles, and avoiding looking directly at the monster. As it is so critical to the player, we wanted it to not only work, but to feel like a real mirror. 

Making mirrors in games is a hard thing to do, and with only four weeks development time for the entire project, it became a tall order. So, to mimic a real mirror as easily and accurately as possible, I used a second camera that renders what it sees onto the mirror.

1.  A camera by itself would not behave like a mirror. To give it more qualities of an actual mirror, I made the Mirror Camera rotate in the same way a mirror would reflect light.

I took the Player Camera position and get the Direction between the Camera and the Mirror. Then that Direction is mirrored and the Mirror Camera is rotated accordingly.

2. A mirror also has a lesser field of view the further away you are from it.

To mimic this, the Mirror Cameras Field of View is interpolated between two values. The closer the Player Camera is to the Mirror Camera, the bigger the Field of View gets. If the Player Camera gets further away, the Field of View gets smaller.

 

Additional
Monster Visibility

Looking directly at the monster will alert it and then kill you, if you look at it long enough. To detect if you are looking at it, I placed a socket on each of its limbs. For each of the sockets, I detect if its location is within the player cameras view. This does not detect if there is anything in-between the camera and the socket though. To make sure that there is nothing in-between, I then cast a ray from the camera to the socket. If the ray hits nothing, then at least one limb of the monster is in full view of the player..

Rotation

The game is set within an abandoned hotel, which means there are a lot of corridors and turns. As the game was developed with the Oculus Rift, real life rotation is very limited as the system only have sensors from one direction. 

My solution to allowing the player to rotate more easily rotate is by using the thumb stick. By flicking it right or left will rotate the player either 45° or 90°, something you can adjust. This allows you to navigate corridors more easily without having to turn around in real life. Then, flicking the thumb stick back will rotate the player 180°, making it easier to go back or to run away from something. 

Rotating the player in a traditional game would be easy to do, but with the game being in VR causes a few problems:

1.  The Player Camera is a child of the player Actor, which in turn is always positioned at the center of your play area. When you move in real life, only the Player Camera moves, the Actor mimics where the center of where your play area is.

So, if we only rotate the Camera then things would no longer line up with the real world and the Actor. Walking forward in the real world would be to the right in the game world.

2. If we instead rotate the Actor, the Camera will rotate with it, as the Camera is a child of the Actor.

3. But unless the Camera is directly on top of the Actor, it will also move while rotating as it is a child of the Actor. If the Camera is close to the Actor this is fine, but the further away the Camera is to the Actor, the more it will more around. This can cause massive confusion and can also “teleport” the player into objects and Walls.

4. My solution is to rotate the Actor around the Camera. The Camera will stay in the same position, and will keep the same relation to the real world. Sometimes this will cause the center of the play area to be behind a obstacle, but now the player is always in the same position.

 

Post-Mortem

Making a game in VR taught me massive amounts about designing and working around performance challenges. We had to optimize all our graphical effects and had to limit our game design to always maintain a stable frame rate. It also challenged me to quickly adapt to something new and unfamiliar in a short time.