The VR escape room game project - part 3

The puzzles in the escape room are all in a different scene, but they all use the same garage as location. Whenever the players complete a puzzle, the scene is changed and they are presented with the next puzzle. This is achieved by calling the SceneManager.LoadScene() method. 

The player can also teleport or use snap turns instead of walking around, making it easier to explore the whole room, even if you don't have enough space in real life or want to stay stationary. This is achieved by the Locomotion System under XR Origin, which has 3 scripts: Locomotion System, Teleportation Provider and Snap Turn Provider. On both controllers, there is an XR Ray Interactor and  XR Interactor Line Visual script which show a line coming from the controllers to help players visualize where they want to move. The floor is set as the Teleportation Area, so players can only teleport within the room. 

Locomotion System Scripts
Controller Scripts and components


Puzzle 1 - Buttons:

In this puzzle, the player in VR can see 2-4 buttons and some different tools on the tool rack. "Mission control" has to decide based on the number of buttons and which tools are present, which is the correct button to push. When the correct button is pushed, the puzzle is completed. 

There are 12 scenarios in total, and the current scenario is decided by a random number generator. Then based on the number, the correct scenario is set up by setting the correct tools and buttons to active in the scene and saving the correct button to push. Then on button push, it's checked if the pushed button is the same as the correct button. If it is, we load the next puzzle. If it's not, a new scenario is created and the players have to start over. 

A scenario is set up with the correct game objects activated
A scenario is set up with the correct game objects activated


Puzzle 2 - Sound:

The player in VR has to determine where the sound is coming from and interact with the correct object. When they do, a victory sound will play and then they have to interact with the small stool to complete the puzzle. 

The audio source is set randomly to one of the target game objects (e.g. table, locker) which can be the current object that emits the sound. Then the interactable of that game object is saved in a variable and a Coroutine is started to play the sound on a loop. On Update we check if the saved interactable is selected. When it is, the Coroutine is stopped and the player has to interact with the stool to complete the puzzle. After they do, the new puzzle is loaded. 

A possible audio source is set as Target
The stool is set as SecondTarget, which completes the puzzle

Puzzle 3 - Labyrinth:

The player in VR has to walk around the square grid on the floor to see the favorite tool, then they have to walk around the room to find that tool, which has a code on it. Based on the code, "mission control" can determine the blueprint for the labyrinth and guide the VR player through it. There is a correct path the player has to go through to grab a cube at the end. When they have that cube, they have to throw it on the correct square to complete the puzzle. 

The favorite tool, it's position and the labyrinth blueprint are all decided based on a random number generator. Each square in the grid has a trigger. When the player comes in contact with one of the squares, it's checked whether the player is allowed to touch it. If not, the player's position is reset to the beginning. When the player comes in contact with the correct square, they are allowed to stand on it, and continue their path through the labyrinth based on the blueprint. The same technique is used to determine if the cube is placed on the correct square. After it is, the players have completed the last puzzle, and thus won the game. 

Code on the tool
Favorite tool

Author: Anett Barát











Kommentarer

Populære opslag fra denne blog

XR project final part and XR Expo

Individual reflections - Kristóf Lénárd

Individual reflections - Christian