Getting Started
Getting Started
Samples & Examples
Core Concepts & Glossary
Unity Package Types
Spaces & Space Templates
Custom Avatars
Custom Avatar Animations
Avatar Attachments
Custom Prefab Objects
Components
‣
‣
Quests and Rewards
Drivable Vehicles
Economy
Economy Overview
Monetization
Items
Consumable Items
Rewarding Items
World Currency
Selling Items
Scripting
‣
Guidelines
Supported Features and Limitations
Performance Guidelines
Lighting
Publishing to Spatial
Finding Published Packages
Support
FAQs
Help and Community
Release Notes
Asset Import Settings
Synced Object
This is an experimental component, It is likely to receive large changes in the future!
Before using the synced object component make sure to familiarize yourself with Spatial Netcode.
Spatial Netcode Introduction
The synced object component lets you mark a scene object or prefab as “synced”. This causes the objects transform, lifetime, and custom variables to be synced across all clients in a space.
Embedded vs Prefab
Synced objects can either be embedded in a scene or be instantiated as a prefab using visual scripting. The core behavior of the component acts the same between the two, but the following properties have slightly unique behavior depending on how the object is created.
Properties
Property | Function |
Sync Transform | If enabled the objects transform will be synced across all connected clients. |
Save With Space | Checked:
The state of the object will remain consistent across sessions. A new session starts when a user joins an empty space. As long as one users is connected to a space the session will continue.
Unchecked:
Embedded scene objects
When a new session starts embedded scene objects will always be instantiated, even if they where deleted in a previous session.
Instantiated prefab
When a session ends all instantiated prefabs will be deleted. |
Destroy on Creator Disconnect | * Only relevant for objects instantiated as a prefab through visual scripting
If checked, the object will be destroyed for all clients when it’s creator disconnects. Note an objects creator does not equal its owner. |
Synced Variables
You can optionally enable synced variables on your synced object. This allows you to keep Visual Scripting variables synced on the same object.
Synced Variables follow the same ownership rules as the transform.
Only
bool
, int
, float
, string
, Vector2
, and Vector3
can be synced.How To Use
Embedded scene objects
Creating an embedded synced object is as simple as just adding a Synced Object component to any of your scene objects. From the hierarchy view you can easily see which objects are synced by looking for the sync icon on the side.
Prefab Objects Creating a synced prefab object is just as easy but requires a few extra steps. First we need to create a prefab that has a Synced Object component on the root object like so:
This prefab can live anywhere in your project folder.
To instantiate this prefab you can simply use the GameObject.Instantiate
node like normal. Spatial will make sure the object gets instantiated on all other connected clients and syncs properly.
Limitations
Only the LOCAL transform is synced
If you re-parent a synced object on one client, that change will not propagate to the other. The synced object will still behave “normally”, but it’s position might become de-synced since it will be relative to its parent.
A synced object can not be a child of another synced object
← Previous