Getting Started
Package Types
Scene Setup
Economy
Scripting
Components
Guidelines
Support
Quick Start FAQ
How do I use my own camera?
You can not upload a Camera
component to spatial, but you can use Virtual Camera
's to take full control of the camera and use the CameraService to access the Camera.main
properties
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.
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
component.
How do I control the Player Camera?
We do not recommend trying to modify the default player camera. Instead you should override it with a Virtual 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.
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.
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
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.