The Making of Duck Hunt VR

A few weeks ago, we spent a weekend making a quick VR homage of DuckHunt, just to test the Oculus Touch controllers. We know we're not the first Duck Hunt VR out there, but we hoped we could bring something amusing to it. Not a final product by any means (no UI, for example), but we needed to piece together how the Touch controllers differed from the Vive controllers. Although we've been testing VR in both Unreal and Unity, we chose Unity since it's so easy to get set up with the Oculus SDK.

We’ve had some people ask what it takes, so here’s a high level overview.

The Sprites

I'm the duck in the box

I'm the duck in the box

A quick Google image search gave us the majority of the sprites we needed (in fact, almost any classic game sprites are readily available). For the ducks and dog, we were able to use the exact sprites from the original game. But for the environmental sprites (trees, grass and bushes) a little Photoshop work was required to break them apart and extend them - after all, they were now going to be placed in 3D space so you'd be seeing more of them that what was contained in the original art.

The ducks received an extra layer of interactivity, in the form of a Box Collider to intercept the Raycasts coming off the guns (for hit detection)

Animation

Say hello to my little friend

Say hello to my little friend

There are two types of animation in the project: programmatic and dynamic. The ducks were entirely dynamic - upon creation, each duck would generate a random speed and direction, and then continue to use that logic to switch back and forth. For the dog and the "2017 version" pistols, we used Unity’s state-based animation system and programmatically listened for a simple trigger. The ducks also contained a small state system, tracking their animation status of: flying, shot, or falling.

The Controllers

Pew, pew, pew

Pew, pew, pew

We used the Oculus SDK for our motion controllers. We thought about using the SteamVR plugin for Unity, but we’ve already had some experience with that and wanted to try something new. Also, the ghost hand rendering that comes “for free” with the Oculus SDK was perfect for our punchline: switching from gun mode to grab mode. After connecting the guns to an Oculus Avatar, an empty GameObject was placed in the barrel of each gun and used as a Raycast emitter for duck detection.

A listener was placed on the A Button to toggle between 1984 mode (Zapper) and 2017 (dual pistols). Clicking the right analog stick, removed the guns entirely and put the user into interact mode: where we utilized the Oculus Grabbable code for picking up the grenade models.

The Level Design

Easiest level design ever

Easiest level design ever

Fortunately for our quick build, level design in DuckHunt is very simplistic: grass, trees and bushes. We chose to keep all our assets as Sprites and build the world in 3D space (then controlling the Sprite sorting order). For the sake of time (and to match the basic look of the original), we only did two “layers” deep into the 3D environment (just enough to give the world a sense of scale to the headset wearer). We then curved the environment to around 90 degrees in either direction, just to have some level of immersion (sorry, no room scale yet...) The only challenging part of the level design was dealing with Unity's Sprite layer numbering system. (after some trial and error, we discovered that positioning the Sprites with positive layer numbers actually occluded the Touch ghost hands. Moving our layer numbering into negative numbers fixed this.)

The Ducks

Everybody out of the pool

Everybody out of the pool

We needed a very different number of ducks for our 1984 and 2017 versions, so we created a simple emitter with customizable options. That allowed us to place each emitter in the 3D scene and independently control spawn speed, maximum ducks and their initial delay values. For example, the 1984 version had a slow initial speed with a two duck maximum. For the amped-up 2017 version, we used 12 emitters, with a fast spawn rate, a series of delays (so they all didn’t start simultaneously), and no maximum ducks.

One cheat we had to make was with the audio: each duck was originally its own AudioSource for flapping and quacking sounds. When you had 50+ on the screen simultaneously, it became maddening. The primary Duck class was given a static array of all ducks, which grew as each were added - making them aware of their brothers. After 20 ducks on screen, we simply didn't allow any new audio.

The Finale

The Big Bang

The Big Bang

The 2017 version needed a big ending that paid homage to the 8-bit era, and something that made use of the motion controls. We felt the best way do that was with a grenade and the end-boss explosion sprites from Contra. To achieve the staggered animation effect, we created a simple Explosion class, with each instance monitoring the total number of sibling explosions. At run time, they were then assigned a small delay based on their birth order. In other words, we could simply duplicate and drag/drop explosions, and the animation system would automatically take care of the timing and depth.

Final

We decided early on that our little experience wasn't going to be released publicly for two main reasons: 1) we're using this code base for an unrelated upcoming project, and 2) Nintendo lawyers are terrifying. Instead, we felt the best way for our Duck Hunt VR to live on was through this little video: