Spectating VR

This project was created in tandem with the Spectating VR Blog Post.

A Note about Asset Sources

Assets for this project were gathered from internal training resources, with one exception. The player's assets are made purely from Unity primitives.

Project Structure

Project structure is split into various graphical elements, gameplay prefabs, spectator render target materials and textures, the primary scene, and scripts. The graphical elements are split in two, to make it easier to delete what you don't need without inadvertently breaking any prefabs.

Environment

These are various assets required for the overall scene. This is predominantly the skybox, distant buildings, and platform. These can be wholly deleted if you are looking to just use the spectator mechanics, and are only referenced within the Environment gameobject in the main scene.

Graphics

These are more locally used assets, including the borders for render targets, cameras, UI text, and player avatar. These assets are linked to various prefabs, and should be more carefully swapped out in individual prefabs before deleting.

Prefabs

Contains prefabs for the player, cameras, spectator system, and displays. More on the spectator system prefab below.

Scene

For now, just one primary scene, this is the starting point for this sample.

Scripts

The simple scripts that get everything working. I tried to keep it minimal, easy to understand, and adjustable, so even those not very comfortable with programming can hopefully get an idea of how it's working.

Scene Structure

The scene is located at Assets/Scene/SpectatorSample. The most important elements for understanding the spectator system here are the SpectatorSystem prefab, Cameras to see how each of the activateable cameras function, and Player to see the simple player rig. Another interesting element could be Environment/SpectatorDisplays which shows how I set up the ring of preview cameras.

Deleting Visuals

I've tried to name all visual elements under either Canvas if it's a 2D, UI element, or Visual for all 3D objects. This means that if you'd like to sub-in your own imagery into this demo or take the mechanics without the visuals, you should be able to search for Visual and Canvas in order to identify the visual elements that need to be replaced.

Spectator System Prefab

The Spectator system consists of 2 cameras. There is static, direct-to-screen camera that is used to overlay any spectator-only UI. This camera is located at SpectatorSystem/SpectatorView. The other camera is moved from place to place and is used to position where the spectator is looking from. It is located at SpectatorSystem/SpectatorCamera. Both are managed by the SpectatorSystem::SpectatorController script. The bulk of what it is doing is moving the Camera Transform through the set Attachment Points, and checking for requests to move to the next attachment point.