Why so many VR experiences do Snap Turn wrong

Last week, Wyatt and I were talking about a phenomenon that occurred as he walked through an early level of Gaia, our virtual reality immersive story. He told me he was teleporting his way through a cave and when he snap-turned to better adjust his view, he passed straight through the virtual cave's wall into an infinite fall.

He was describing a bug in our experience, a bug that I had actually encountered before, not just in Gaia but in many other virtual reality experiences. So I decided to investigate what was happening, and came across a very interesting snap turn phenomena. But before I tell you all about it, what is a snap turn?

What is snap turn?

Moving through virtual reality is a weird thing because it often involves two kinds of motion, the one you do with your real-life body and the one you do by pressing buttons on a controller. So how does this work? Imagine you are on the last seat of a bus. When you walk to the front of the bus, you've moved through space, and traversed part of your journey. Walking through the bus is kind of what happens when you walk inside your room while wearing a VR headset: you've moved both in the real and virtual world, and like a bus, the space you can walk around is limited. When the bus drives through the world, you are also traversing the world, except that in this case, the bus driver is doing all of the work. Being driven by a bus is equivalent to pressing a button on your joystick and moving through the virtual world while standing in the same "real place". In virtual reality, we call that bus the "rig." So what happens when you want to turn around in VR? The same still applies, you could turn your real body to see what's behind you in the virtual world, but because most headsets have long cables attached to them, you would quickly find yourself tangled with wires. The alternative is to turn the entire bus, often by 45 degrees in one click of a button. We call that a "snap turn," and this locomotion system can be found in most popular VR titles.

 
 
 

Snap turn phenomena

So why did snap turning caused Wyatt to fall through the world? When I programmed the snap turn system for Gaia, I started by simply rotating the bus by 45 degrees when the player moves the joystick left or right. If the player happens to be in the very center of the rig (or bus) when they snap turn, they'll have successfully turned around the virtual world, maintaining the same position. The problem occurs when the player walks with their real body to the edge of their "bus" and then snap turn. The bus spins on its axis, but they’re not in the center of it any more — so as well as rotating, their position also gets moved. Perhaps even through a virtual wall.

 
 

Why is it so common?

So why so many games and VR development tools do it wrong? I believe it has something to do with the fact that most programmers set up their VR systems so that their computer chair is at the center of their rig (bus). When they play-test their snap turn it looks like they’ve rotated around their head. But not everyone stays sitting down for the whole time they’re in an experience. The other factor may be that most programmers, including me, create special “sand box” worlds for developing their locomotion systems. These worlds are environments full of ramps and obstacles to test the functionality of locomotion, but they are often wide spaces in which the play-tester is unlikely to find themselves next to a wall and snap turn their way into the virtual void.

 
maku-xr-vr-gaia-snap-turn-unity-zanforlin.png
 

The solution

When I realized snap turning wasn't as simple as just rotating the rig, I came up with another easy and intuitive solution. I would snap turn in three steps. First, I'd record the position coordinates of the player's head before they perform a snap turn. Then I'd apply the rotation. And finally I would reposition the bus so that the player's head is back at the original recorded position. All in the blink of an eye. I thought the final step of moving the rig to a position so that the player's head would involve something like recording the distance between the player and the center of the bus, which we'll call p, and moving the bus to the desired location subtracted by p. This is essentially the calculation I had to do when designing Gaia's teleportation system.

 
maku-xr-vr-snap-turn-zanforlin.jpg
 

But when I started to draw this system on my whiteboard I quickly realized that things were more complicated than it seemed. I drew the three steps, recording the initial position, rotating the bus, and moving the bus, but no matter how I looked at it I couldn't find a consistent formula that would move the bus to the correct location that worked for both clockwise and counterclockwise rotations. The solution had to be something more involved, some form of axis-dependent rotation that would do all the steps in one simple gesture. Something mathematical. That's when I came across a simple code command called "RotateAround" that received as input the rotating object (the bus) and the position of the rotation axis (the player's head) and in a magical one-step process it snap turns the player while maintaining its position.

 
makuxr-gaia-correct-snap-turn-zanforlin_1.gif
 

I'm going to be honest with you, I don't fully understand exactly what “RotateAround” does inside its code. Virtual rotations are based on quaternions which are unintuitive mathematical abstractions of angles and axis and I am not good at math. In fact, what I love about programming is that computers do the math for you and you often don't need to have a clue about how things work — you just need to know how to use it.

If I can think of any takeaway from the experience of developing a good snap turn system it is that simple things are often harder to build than they look, hard problems sometimes have easy solutions, and sometimes good programming is more about understanding the outcomes than understanding the code itself.

Luis Zanforlin

I'm a media composer, sound designer, and virtual reality developer with an interest in arts and education. Currently, I work as a virtual reality developer at MIT where I create new media experiences and assist in teaching a class in virtual reality & immersive media.


http://luiszanforlin.com/
Previous
Previous

Locus - Spatial Music Notation

Next
Next

Sketching Music for Immersive Media