Getting Started

Introduction

Installation

Project Configuration

Testing in Your Sandbox

Samples & Examples

Core Concepts & Glossary

Package Types

Spaces & Space Templates

Custom Avatars

Custom Avatar Animations

Avatar Attachments

Custom Prefab Objects

Embedded Packages

Drivable Vehicles

Scene Setup

Testing In Unity vs Sandbox

Controlling the Camera

Custom Collision, Layers, and Tags

Audio Mixers and Groups

Key Differences from Standard Unity3D development

Economy

Quests and Rewards

Economy Overview

Monetization

Quick Start FAQ

How do I use my own camera?

Virtual Camera

Can I use Cinemachine?

I need to access Camera.Main

How do I control the Player Camera?

Overview

Spatial uses a virtual camera system and blocks the usage of Camera.main and related API’s. However we supply replacements for nearly every use-case.

Frame 8316.png

Player Camera

By default every space includes an Avatar for the local player which has a Player Camera active. This camera responds to users mouse or touch inputs.

The player camera can be influenced with various methods inside the CameraService such as Shake() , but is not meant to be fully controlled with scripts.

Virtual Camera

In the creator toolkit you can create a Spatial Virtual Camera to completely override the default player camera. When a virtual camera is active you have full control over the camera transform and FOV. You can have multiple virtual cameras in your scene at once and blend between them by changing their priority.

Cinemachine

Under the hood this is all managed by Cinemachine. The Spatial Virtual Camera is simply a wrapper around the Cinemachine.VirtualCamera and a CinemachineBrain powers it all.

You can use Cinemachine virtual cameras and select other cinemachine features yourself by importing the package into Unity. The toolkit does not support additional Cinemachine brains or managers in your scene.

Click here to view a sample using Cinemachine

Priority

The Player Camera has a base cinemachine priority of 10. This means any Cinemachine virtual cameras you use in a toolkit space will require a priority higher than 10 to take effect.

Spatial Virtual Camera's have a base cinemachine priority of 2000. You will need to set a cameras priority to 2001 or higher to override them.

LookAt Local Avatar

To set a virtual camera’s Follow or LookAt target to a player’s avatar, you can access an avatar’s bone transforms via IReadOnlyAvatar.GetAvatarBoneTransform.

Accessing Camera.Main

Spatial does not allow you access to the main Camera component, but we provide replacements for all the important functions inside the CameraService.

//Raycast from the mouse
Ray mouseRay = SpatialBridge.cameraService.ScreenPointToRay(Input.mousePosition);
// Get the screen position of the local avatar
SpatialBridge.cameraService.WorldToScreenPoint(SpatialBridge.actorService.localActor.avatar.position);
//Get camera transform no matter what virtual camera is active
Quaternion cameraRotation = SpatialBridge.cameraService.rotation;

How Do I Use The Thumbnail Camera

Thumbnail Camera

The Thumbnail Camera is used to auto-generate thumbnail images for your space. The thumbnail camera is never used to actively render your space during gameplay.

Simply place the thumbnail camera somewhere with a good view and forget about it.