Unity3D Spectator Mode in VR

If you’ve seen many VR games recently, you’ve probably come across ‘spectator mode’ in at least a few of them.  Games going back to Holopoint and big hits like Rick & Morty both implement their own spectator modes.  Luckily, creating a spectator mode is actually very simple, though there are some things to consider when you do it.

The Spectator Camera

The first thing you’ll need to do is create a new camera in your scene.

Next, take a look at the “Target Eye” field.

Set it to “None (Main Display)”

Now position the camera where you want the spectator view to be.

You can make it a child of the play area, set it in a static position, or create a script that allows the user to move the camera freely using mouse and keyboard.

Adding a generic mouse look/move script from the asset store would give you a free move camera.

What do I show?

Most VR games without a spectator mode or multiplayer functionality don’t show the local players body.

The best thing to show however isn’t a full body, instead, I recommend you show the head and hands only.

As a sample, I created a basic head out of 3 spheres and attached it as a child of the CameraRig’s camera.

When I play now, the spectator camera looks like this.

 

A Problem – The Inside of the Head…

If you copy what I’ve done so far, you’ll quickly realize an issue… right when you put on the headset.

Two big black circles… it’s the eyes!

We have an easy fix though.  Set the head (or body if you use a body), to be on a different layer.

Now select your main VR camera and adjust the culling mask to deselect the PlayerHead layer.

Problem solved!

Now the head and eyes won’t be rendered by the VR camera.

 

Other Considerations

It’s very important to note here that adding this spectator view comes at a performance cost.

You’re now rendering for another camera, and depending on your game, this could be a big performance hit.

In general, I’d recommend having spectator mode be OFF by default and allow it for people who want it, but give them a warning that it can impact performance. (Rick & Morty does a great job of this)

Also, if you do setup a spectator mode, go wild on what you allow the player to do..  let them view the game from the sky, behind the player, maybe even as an ant or some select NPCs in your game.. and just make it fun to watch 🙂