Multiuser

Multiuser Functionality in realvirtual.io

Overiew

realvirtual.io offers multiuser functionality, enabling seamless collaboration and synchronization across multiple computers or running Unity instances. This feature synchronizes drive positions, signals, and multi-user (MU) positions between a designated host and connected clients. Here’s how it works:

Key Features:

  • Synchronization: All drive positions, signals, and MU positions are synchronized between the host and clients in real-time.

  • Host Configuration: There is always one designated host in the system responsible for physics simulation, including collision detection and resolution.

  • Networking Setup: Currently utilizes Mirror networking framework (visit Mirror) for local network communication, ensuring efficient data exchange within local environments.

Development is underway for a Socket.io-based communication layer, expanding connectivity capabilities beyond local networks. This upcoming feature will enable cross-boundary communication, facilitating connections across different networks and environments.

First steps with the demo model

For a quick start, we recommend using the demo model located at Assets/realvirtual-XR/DemoMultiuser.unity. Follow these steps:

  1. Compile the Demo Model to Build:

    • Add the demo scene to the build settings in Unity.

    • Build the project as a Windows executable.

  2. Connecting to Unity Editor:

    • Start the built executable.

    • Switch to client mode using the UI at the bottom of the screen by selecting "Client".

    • The scene will operate in standalone mode until a host joins.

For more advanced users and custom development, consider using Parallelsync, available on GitHub at ParrelSync. Parallelsync allows running multiple Unity instances on the same project simultaneously. However, for basic functionality, compiling the build as instructed above is sufficient.

Now start the same scene in your Unity editor and switch, if necessary, to "Host" mode. Once the client is connected, you will see a message similar to this:

Now you can control the scene in the Unity editor. For instance, move some MUs using your mouse in scene mode, and you will see that the client exactly follows these positions.

Multiuser components

Multiuser Connection

The main component of the multiuser functionality is the "MultiuserConnection," which is available as a prefab located at Assets/realvirtual-XR/MultiuserConnection.prefab.

Imverse Controller

Within this prefab, the "ImverseController" automatically adds "Imverse" components to all necessary components in the scene that require synchronization. This process occurs dynamically based on whether the client is entering as a host or when clients are connecting to the host.

Imverse Communication Mirror

The "ImverseCommunicationMirror" component within the Multiuser Connection handles the Mirror connection setup. Here's how you can configure it:

  • IsHost: Set this to true if you want this instance to act as the host. Set it to false if it should act as a client.

  • AutoConnect: When enabled on the client side, it automatically attempts to connect to a host when the application starts.

  • Network Address: On the client side, specify the network address where the host is running. For example, use "127.0.0.1" for localhost. This setting is ignored on the server side.

Imverse Components

Once the connection is established, components such as Drives in the scene are equipped with an additional "ImverseDrive" component. These components manage key information including an ID (e.g., /ConveyorBox) and a Status (e.g., "Owner"). The ID uniquely identifies synchronized components based on their path within the scene. It's crucial to maintain unique naming conventions within each path to avoid conflicts. This uniqueness is automatically verified at the simulation's start, and any issues with non-unique naming are logged in the console.

When a component acts as an owner, it sends information to all connected clients. Conversely, if a component acts as a consumer, it receives information from the owner.

The following Imverse Components are available:

  • ImverseDrive: Added to all Drives for syncing their position, represented as a float value.

  • ImverseMU: Added to all MUs (Moving Units) for syncing their position (Vector3) and rotation (Quaternion).

  • ImverseUser: Added to the User, syncing their position and rotation. The position of the local User is always synchronized to the camera's position in the local instance. For other users, their positions are synchronized to their respective positions.

  • ImverseSignal: Syncs signal values across connected instances.

These Imverse components facilitate seamless synchronization of positions, rotations, and signals across the networked environment, ensuring consistent simulation experiences for all connected users.

Multiuser Connection Status

The "MultiuserConnectionStatus" prefab, found at Assets/realvirtual-XR/MultiuserConnectionStatus.prefab, serves as a UI display element for managing Client and Host modes within your scene. To integrate this prefab, simply drag it into your scene where required.

This prefab is responsible for managing Host and Network settings within the "ImverseCommunication." If you opt not to use this prefab, you'll need to manually configure these settings within the Multiuser Connection component.

Last updated