Looking Glass Demo (Prey 2016)
With Deathloop releasing last week, I wanted to give myself another week-long challenge for a demo. My immediate thought was as part of the opening level to Prey (2016), where (spoilers if you still need to play the game) Morgan Yu has to smash the looking glass to escape from the apartment/experiment. So, I wanted to see how well I could recreate that moment in Unity.
Initially, I broke down this moment into three large chunks to cover:
- Recreating the looking-glass effect.
- Creating the glass smashing.
- Having the lab environment appear.
These three points I wanted to cover were my starting point for this project.
The first step of my project was scouring through the Unity Asset store and finding the various assets that would fit the environment. I had seen a modular apartment asset pack, which I first imported, and, using a reference photo, I tried to replicate the apartment as closely as possible in-game. From there, I found more models and assets for the city, the wrench, and a modular laboratory scene.
Creating the looking-glass effect ended up being more straightforward than I had anticipated. My initial plan was to replicate the shaders commonly used for shop windows (where cubemaps are mapped to a room and rendered to create a parallax effect) and modify them to render outwards. However, with some tweaking, the resulting shader worked, but it ultimately looked flat and had no depth. As a result, I looked into some other solutions. After re-watching the Noclip Documentary about this level in Prey, I ultimately decided to go with the most straightforward route: having several buildings rendered in the game scene. While this game had a much better visual result, there were some drawbacks, with more meshes now needing to be rendered at runtime. Luckily, the performance hit was not too noticeable.
With the environment set up, I set my sights on setting up the glass-smashing system. I imported an FPS model and script I had used in a previous project, as well as attaching a wrench to the character (while in the actual level, Morgan picks up the wrench in the hall, for the conciseness of the demo, I decided to have him already holding it a runtime). After realizing that I had no wrench smashing into glass animations, I went to Mixamo and downloaded several melee animations that would work for the scene. The animation portion was ready to go after setting up the animation controller and the controller with the character script.
In Unity, I created another script for the prefab of the wall that the player would smash. This controller handled the collision from the colliders added to the wrench and the wall. When the collision is detected between the two, a "lives" system will tick down (this is to account for the player in the published game being able to smash the Looking Glass multiple times). The first impact causes a decal to appear on the glass, and the second time causes the glass to shatter apart completely.
I achieved the shattering glass effect by using ProBuilder. For simplicity, I used a plane and the glass prefab in ProBuilder using the boolean tool combined with a cube to break apart these meshes into smaller pieces. The aircraft contained a window texture, which creates the illusion of a screen breaking apart behind the glass. After adding a rigidbody to each piece, the parts would fall to the ground when the prefab is instantiated, creating a waterfall effect.
After the setup, the larger pieces were finally able to come together. Using the controller script for the looking glass, I could set the different prefabs as active or non-active depending on the conditions within the scene. I made some glass-breaking sound effects to add more polish to the scene to match wrench striking. Finally, to add more visual context to what's occurring within the game, I cut the overall speed to half-time. This change in timescale would emphasize Morgan's discovery that the apartment is fake and that he discovered his way out of the cycle.
Overall, this was an enjoyable project to work through. It was one of the first demos where the object was to work backward, in that there was a finished product that needed to be reverse-engineered. I enjoyed working on this demo and would love to do more projects like this in the future!