Getting Started
Package Types
Scene Setup
Custom Collision, Layers, and Tags
Key Differences from Standard Unity3D development
Economy
Scripting
C# Scripting
Visual Scripting
Sync and Multiplayer
Components
Environment Settings Overrides
Render Pipeline Settings Overrides
Guidelines
Supported Features and Limitations
Support
<aside> ⚠️ This is an experimental component, It is likely to receive large changes in the future!
</aside>
<aside> <img src="/icons/hand_red.svg" alt="/icons/hand_red.svg" width="40px" /> Before using the synced object component make sure to familiarize yourself with Spatial Netcode.
</aside>
<aside> <img src="/icons/book_gray.svg" alt="/icons/book_gray.svg" width="40px" /> 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.
</aside>
<aside> <img src="/icons/light-bulb_blue.svg" alt="/icons/light-bulb_blue.svg" width="40px" /> 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.
</aside>
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. |
<aside> <img src="/icons/code_gray.svg" alt="/icons/code_gray.svg" width="40px" /> 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.
</aside>
<aside> <img src="/icons/cursor-click_gray.svg" alt="/icons/cursor-click_gray.svg" width="40px" /> 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.
</aside>
<aside> <img src="/icons/no-entry_red.svg" alt="/icons/no-entry_red.svg" width="40px" /> 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.
</aside>
<aside> <img src="/icons/no-entry_red.svg" alt="/icons/no-entry_red.svg" width="40px" /> A synced object can not be a child of another synced object
</aside>
← Previous
Next →