Camera Management: Settings and Switching
How to use VIVERSE SDK's CameraService to manage camera settings and switch between different VIVERSE and custom cameras.
VIVERSE provides a powerful camera system alongside its player controller and input scripting that allows developers to switch between different views and control various camera behaviors. This guide will show you how to implement camera switching in your VIVERSE project.
Basic Camera Switching
The VIVERSE player rig creates several cameras and switches between them depending on your settings and/or world scripting: CAMERA_3RD
, CAMERA_1ST
, CAMERA_VR
, CAMERA_ORBITAL
are all separate in the scene hierarchy.
The CameraService
provides methods to switch between different camera views provided by the VIVERSE avatar rig. Here's a basic .mjs script importing the CameraService
and switching to first-person camera mode on init. Simply attach this script to any entity in your project.
NOTE: this script asset must be placed in
/scripts
or another subfolder, since it assumes the VIVERSE SDK is one level up, located at:"../@viverse/create-sdk.mjs"
- or you can alter this import path as needed.
Custom Camera Override Example
If the VIVERSE player rig cameras don't totally meet your needs, you can switch to your own camera entity for cut scenes or preview cameras. Here's a practical example of how to override the default VIVERSE camera with a custom camera on init:
Camera Switching on Events: VR and Player Ready
You can listen for certain events from other services that may be related to your desired camera behavior. For example, on the player:ready
event, we know that all player cameras and scripting have loaded in and are ready to interact with the scene:
Additional Camera Properties
The CameraService
provides several properties to customize camera behavior:
Additional Resources
Last updated
Was this helpful?