Bringing the Mountain to Muhammad

19. July 2016 Design 3
Bringing the Mountain to Muhammad

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.


3 thoughts on “Bringing the Mountain to Muhammad”

  • 1
    Toby on July 19, 2016 Reply

    It is not a new problem, but you are right that someone may be looking for the solution now. Is your terrain based on a tile system?

    • 2
      The Undead Dev on July 19, 2016 Reply

      Yep, which makes the solution a little easier to implement in my case.

  • 3
    Toby on July 19, 2016 Reply

    Nice. I am not using a tiled terrain, but I have been thinking about slicing the entire terrain into sections for better loading, as the environment is crowded with objects and animations. The main problem is that reduces the visibility range severely once the player gets up high – there are mountains. Haven’t figured out a solution to that yet.

Comment on this post!