A Better Solution to Collecting Kittens in KittenVR

Blog Posts ,Programming ,Software ,Unity
December 12, 2015

Hey everyone!

After a whirlwind of activity over the past few months, I have finally had the chance to pick up where I left off on KittenVR! I’m going to be sharing more details and a new version of the app soon (!) but I wanted to jot this out for you because it made me realize that I was operating under a few bad assumptions with my game that I’ve only recently had the chance to improve on.

kittenvr christmas

If you had tried playing the most recent versions of KittenVR, you probably noticed that my raycasting and collision detections on the kittens were pretty awful. Half of the time, without an Xbox controller, the collisions didn’t work the first few times, which resulted in a lot of frustrating clicking and moving to try and hit the sweet spot for collision detection. That all went out the window when I upgraded to the 0.8 version of the Oculus SDK and runtime and none of the collisions worked.

I was planning to start debugging, but one of my coworkers happened to be meeting with an Xbox engineer at our office on Thursday and introduced her to me while I was working. I mentioned off-handedly that I was struggling with collisions and she asked why I didn’t just do a proximity collection trigger instead.

Sometimes when we work on projects in a bubble, we can over-complicate things because we get stuck on a specific approach. In this case, I had so fixated on how I was describing KittenVR (“A FPS where you collect kittens instead of shooting things”) that I didn’t even stop to think about a better way of building in the collection behavior.

The thing is, KittenVR isn’t a challenging game. It’s not beautiful, it’s not a puzzle that needs intense concentration to solve – it’s just a silly, simple, cute thing that I built to show off Unity and virtual reality to new people. I was focusing too much on what I had seen from other games instead of what made sense for mine.

So, onto the better solution!

I was previously using a small anchor circle to raycast from my player and check to see if it made a collision with anything when the mouse was clicked. This method looked at the tags of the collision object as detected by the player, and reacted accordingly.

void CheckCollision()
   if(Input.GetMouseButtonDown(0) || Input.GetButtonDown("Submit"))
       RaycastHit _hit;
       Ray _ray = new Ray(_anchor.transform.position, 

       if(Physics.Raycast(_ray, out _hit))
          if(_hit.collider.tag == "leader")
          else if (_hit.collider.tag == "kitten")
             GameObject _kitten = _hit.collider.gameObject;

I realized that the game play really didn’t need the input trigger, and went with the proximity sensor approach. The result? A much more playable game! I put a trigger on the kittens themselves, rather than the player, and the kittens detected the collision and destroyed themselves, sending a message to the game controller that they had successfully been collected.

This new code involved changing two settings for the Mesh Collider on each kitten: checking the boxes for “convex” and “isTrigger”. I also updated a script attached to the kittens with two new functions to handle the collisions for collection:

 void OnTriggerEnter(Collider _player)

 // Collection
 public void CollectMe()
     GameObject _EventSys = GameObject.FindGameObjectWithTag(

And with that, the collisions were improved! You could combine these into one function, but I might be adding new parts into the game so I decided to keep this separate for the time being.

There were two key takeaways here for me:

  • Don’t let preconceived notions of game play get too in the way of a clean experience
  • Understand and recognize what the goal of your game is

I didn’t need to make KittenVR behave like an FPS – it isn’t a first person shooter game, so there wasn’t a compelling reason to force the user to click to collect the kittens. The result is a much smoother experience – stay tuned, because the 0.2.0 release will be available soon!

Related Posts

1 thought on “A Better Solution to Collecting Kittens in KittenVR”

Leave a Reply