Immerse

Synchronisation and interaction

Step 10 of 13 |45 mins

Mapping input from controllers

General SDK programming guide

Description

The Immerse SDK and Platform supports built-in, automatic synchronisation of core objects such as:

  • The current active CameraTarget
  • All VR user avatars (head, controllers and position, along with other information such as name and colour)
  • All built-time "known" Interactable objects
  • The Beacon

There are many elements which are not automatically synchronised, which can lead to issues when developing multi-user, collaborative scenes.

These include:

  • Any objects spawned at runtime (whether they are interactable or not).
  • The enabled/disabled state of a GameObject(e.g. lights switched on/off, etc)
  • Animations
  • User Interfaces (such as Canvas, Dialogs, Hand Menu)
  • Any interactable objects moved in code
  • Any object or system state and logic
  • Loading scenes as a result of something changing

Many of the above situations can be fixed by using features that comes with the SDK, but this does not work automatically - some planning and coding is required to get it working.

How It Works

Synchronisation is achieved by securely broadcasting messages between users over the network. All messages are sent to the Immerse platform, which will then "persist" them and broadcast to all current users in the session. Persistence is necessary to ensure that new users joining a session will receive all the messages needed to display the current state of the scene.

The Immerse SDK hides much of the complexity of sending and receiving these messages; they are addressed using an indexing system. Each message holds the unique index of the component they are sent to.

Indexing system

IndexedMonoBehaviour is the base class for all synchronised components in the Immerse SDK. Each instance of this component has a unique Index property that gets saved with a scene.

The Scene object holds the runtime dictionary of unique synchronised components. Each of the IndexedMonoBehaviour instances will register themselves with the scene object when they awake.

📘

Immerse SDK Class Library

More detail available in IndexedMonoBehaviour

The Scene object displays all the indexes that can found found in the currently loaded scene(s)

🚧

Occasionally duplicate indexes can be created by accident (for example, creating a copy of a Interactable GameObject). In this case, the SDK will show a warning of detected duplicate indexes.

These must be regenerated manually by selecting the Scene object in the Hierarchy View, and clicking the Regenerate Indexes button in the Inspector.

When a message arrives, the index is extracted from the message payload and then used to look up the destination component. If found, the message is then forwarded to that component.

The Immerse Platform and SDK support two forms of synchronisation:

  1. Synchronising Interactable Objects
  2. Synchronising State

1. Synchronising Interactable Objects

For synchronising interactable objects, theTransformSync componentis used, which derives from IndexedMonoBehaviour (Note: TransformSync requires a Rigidbody component).
It can synchronise any combination of the following properties:

  • Position
  • Rotation
  • Velocity
  • Angular velocity

📘

Immerse SDK Class Library

More detail available in TransformSync

Each type of interactable object requires a different set of the above properties to be sent.

The Immerse SDK comes with a selection of core interactable objects (also see Interaction Overview.

2. Synchronising State

Sometimes it is only necessary to synchronise data (state). To achieve this, a State Synchroniser component can be used.

For more information on how to use this, see Synchronising State between multiple users.

Mapping input from controllers

General SDK programming guide

Updated 3 months ago


Synchronisation and interaction


Step 10 of 13 |45 mins

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.