Bringing the Mountain to Muhammad

July 19th, 2016

So I’ve been loving my HTC Vive lately. I’ve got a post coming soon about my adventures in amateur VR prototypes, but this week I wanted to talk about a bug I kept hitting and how I fixed it.

The Problem: Controller Tracking It’s super simple and works right out of the box for most people, but it wasn’t always working for me.  My controllers often became delayed or inaccurate while playing and it was pretty frustrating. What’s worse is that no one else online seemed to be having this problem so there wasn’t a lot I could find to help me.

The Cause: It turns out that my problem stemmed from the type of game I was trying to make. I was working on a prototype where the player is constantly moving at a relatively fast pace. I did this by using a custom pawn that implemented physics and then parenting the camera and the controllers to that. It seemed that the faster I moved the pawn and the further I got the pawn from the worlds origin, that the worse the tracking got. Likely caused by some floating point arithmetic errors.

The Solution: Don’t move the pawn. Yeah it seems simple right but unfortunately this solution caused a bigger problem than it fixed. How do you write a fast paced moving game if your player can’t move? Answer: Move everything else in the world. Because of the way perspective works instead of moving my player forward in space I can just as easily move the entire world backwards in space and achieve the same effect. In addition I can do so and maintain perfect tracing for my controllers.

I should mention I didn’t invent this technique.Lots of old school shmups used to use this to make the math a little easier. Now this is definitely not a solution that will work for every game, and one that only works well for me due to the nature of the prototype I’m working on, but it works and I thought I’d share it with you guys in case anyone else was having the same problems that I was.

back to blog