Getting Started
Package Types
Scene Setup
Custom Collision, Layers, and Tags
Key Differences from Standard Unity3D development
Economy
Camera.Main
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.
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.
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.
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
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.
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
.
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;
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.