Controlling the Camera

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. Graphic showing the differences between testing in sandbox vs the Unity editor

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 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

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.

FAQ

How do I use my own camera?

In Spatial, you can not define your own "main camera". Spatial internally manages the camera, instead you should use Virtual Cameras.

The CameraService can be used to access the Camera.main properties.

I need to access Camera.main

All main camera properties and methods can be accessed using the CameraService. We don’t allow access to the internal Camera.main field.

How do I control the Player Camera?

We do not recommend trying to modify the default player camera, the player should be in control of it. Instead, if needed, you should override it with a Virtual Camera.

Can I use Cinemachine?

Yes! Just import the package into your unity project. We don’t support certain components like CinemachineBrain because a brain already exists when you load your space in Spatial.

Click here to view a sample using Cinemachine