I decided to take some time off from developing our next game to get The Night Cafe working with Vive. This experience was originally designed for seated or standing VR without motion controls, although from the beginning I had considered adding support for the Razer Hydra back before motion controls were readily available.
The Night Cafe is a very passive experience in that there is not much direct interaction with characters or objects, although you do have complete freedom of movement within the small cafe space. While it would be great to get more interaction with objects in a future version, for now I just wanted to focus on getting the movement mechanics working well enough to get around comfortably using room scale. This experience is fairly well suited for room scale because it is a small space to begin with, although once I started moving around I realized it would require quite a lot of movement of the player’s space within the virtual space in order to cover the full environment. As a result, I decided a simple teleportation mechanic would be most effective given its wide spread adoption in many Vive experiences.
Getting the Room Size
In the SteamVR plugin for Unity there is a menu to set the room size. I knew I wanted to have a visual representation of the teleport that the player could see so I had to use “Calibrated”, otherwise the teleport size wouldn’t have been correct. Calibrated uses the custom room size boundaries that the player defines during the Vive setup process. Unfortuantely, I could not find a simple class or variable to access the calibrated bounds size but I was able to access the vertices describing the bounds and extrapolate it from that using a switch statement:
Preventing Teleporting Through Walls
I didn’t want players to be able to teleport through a wall and potentially end up outside the environment space. The method of teleportation is to point the controller towards the ground in the area you would like to teleport to. The problem is, even if I had the pointer detect the walls as collision objects, if you position the pointer near the wall but not through it you would still move the teleportation boundaries through the wall like this:
What I needed to do was detect the collision boundaries using a raycast in 4 directions to detect the proximity of the wall to the pointer. Once I had that I could offset the teleport box so that it would not pass through the walls. The pointer would still show exactly where you were pointing on the ground but the box would move to show the bounds. I found this worked quite well.
I also tested having a visual indication of where you are relative to the new teleport position, but this ended up actually being more confusing than helpful. You can see the adjusted teleport box working below. Now when you move the pointer right up against the wall, the box will adjust as needed without going through.
Reorienting the Teleport
I also wanted to make sure the teleport was oriented in the most optimal way so that if a player wants to move to a tighter space, the teleport will rotate at 90 degree angles to best fit into that space. By default I kept the teleport oriented vertically, but if the collision detection indicated a tighter space it would flip to fit. It will also center itself within the space if there is no way to fit it without cropping the sides.
Making Sure the Player is Facing the Right Direction
In most VR experiences it is very important to control where the player is initially facing when the game starts. For The Night Cafe I wanted to make sure they would be standing in the direction that the title screen is displayed as well as the ideal angle to view the environment when it first fades in. With the Gear VR and Rift you can easily initialize the camera to look in the direction you need them to be looking, the only thing you can’t control is whether they are looking up or down. With the Vive, you have to consider that the room space has to be rotated as well so that wherever they are currently looking when the experience starts, the room is rotated to account for their standing position. Not only does it have to be rotated, it also has to be repositioned because the player may not be standing in the center. It is fairly simple to get the headset Y rotation to calculate what direction the player is facing and how much the play space has to be rotated. From there you just need to reposition the CameraRig to your ideal position but offset by the players localPosition within that space. I opted to rotate at 90 degree increments instead of precisely at the correct angle in order to retain the parallel relationship between virtual walls and room bounds.
Overall this teleportation mechanic feels comfortable and makes it easy to get around. I think there is a lot of room for refining the functionality — I particularly like the way Budget Cuts uses teleportation to give you a preview of where you will be before you actually go there. While this might work best in a sci-fi setting, I could easily see it being adopted for other types of experiences as well.
The Night Cafe will be available for Vive on Steam very soon. We also plan to announce our next game within the next 2 weeks so stay tuned and be sure to join our mailing list for the latest updates.