Setup Your Scene

The ability to authenticate as a user and connect to a Space can be implemented manually using calls to our API Functions.

However, in most cases that should be unnecessary. Instead all of that can be managed through the Cavrnus Spatial Connector object.

In this example, we will start with a basic single-user scene:

image-20240208-185029.png

To get started on making this a multi-user experience, you want to first select Cavrnus->Setup Scene for Cavrnus.

image-20240208-191200.png

This will add the Cavrnus Spatial Connector. This object will allow you to configure how users will authenticate and join spaces. It will also spawn a Cavrnus UI Canvas object to display UI under.

Note: There is nothing special about the Cavrnus UI Canvas. It is simply a way for the Cavrnus Spatial Connector to display UI on the screen. If you wish to spawn the UI under your own Canvas (say, for spatial XR) simply select your Canvas and hit Cavrnus->Spawn Cavrnus UI in Selected Canvas. This will redirect the Cavrnus Spatial Connector to use that, and clean up the old Cavrnus UI Canvas.

The Cavrnus Spatial Connector

The first thing to configure inside the Cavrnus Spatial Connector is your company’s URL. By signing up for Cavrnus you should have your own domain which contains all of your accounts and Spaces. Simply type it in.

Note: if you already set your domain in the Welcome popup it should already be filled in here.

Note:

At this point you should be able to hit play and enjoy a working multi-user experience! Your domain comes pre-populated with a Space that the Cavrnus Spatial Connector will attempt to join by default as a guest. However, as you will almost certainly end up wanting to configure things in your own way, you should continue reading.

Authentication

Next, you need to decide how you want people to join your experience. You can choose to have them join as Guests or Members.

Guests can join automatically with no authentication. However, they can only join spaces which you have specifically configured to be available to them (See: Creating and Managing Spaces). These accounts also have a limited lifespan and will be deleted after. This is recommended for delivering an experience to a wide audience who don’t want to bother creating and managing accounts.

To have your user automatically join as a Guest, select Guest Join Automatic. Then choose a name for that user. This is the fastest & easiest way of getting someone into Cavrnus.

You can also allow a Guest to configure their own Name. Selecting Guest Join Manual will spawn a menu under whichever Canvas you are configured to use. This is just a simple menu to type your Name and Join. You can re-do this menu in your own style and have the Cavrnus Spatial Connector spawn yours instead.

Members have accounts on your domain which you or they can create and manage. These accounts will persist, and can be given access to specific Spaces individually. This methodology is recommended for controlling access to private or sensitive information.

We give you the option to execute a Member login automatically by adding their email and password to the project. This option is useful automated testing and for delivering bespoke applications to individuals. However, it involves adding your password in plain text to your project so be mindful when, say, committing these credentials to a public git repo.

The more common way of getting Members into your Application is by spawning a Login Menu with Login Manual. This lets them type in their own credentials and log in as themselves. As before, you can redo the Login Menu as you see fit and spawn your version instead.

We also give you the option to save your Authentication Token locally on your device.

Joining a Space

If you have not yet created a Space for your users to join, you can find the steps to do so here: Creating and Managing Spaces

Once a User is authenticated, you can immediately place them inside a pre-defined Space. To do this, select Automatic as your Space Join Method. You must then get the Join ID of the Space you wish them to enter.

This ID can be copied off it’s entry in the Spaces List:

Spaces can also be configured with custom Join IDs that you can copy:

You can then Paste the Join ID into the given field (Note: by default your domain should come pre-populated with a single guest-accessible space that the default Cavrnus Spatial Connector is already pointing to).

Alternatively you can simply present Users with a list of all the spaces they are currently allowed to join and let them pick one. As before, you can customize this UI as you see fit.

Note: A Cavrnus Space will often be filled with Properties that are specific to a given application. Therefore, allowing users to just open just any Space could result in them bringing down data that is meant to be for a different application.

Example: One of your users has access to a Car Configurator Application which connects to the “Car Config” Space. They also have access to a Conference Room Application. Allowing them to join the “Car Config” Space from the Conference Room Application would give them a bunch of car-related Properties which their Application wouldn’t know what to do with.

Space UI

Once your users connect to a Space they may want to see some menus appear. The Cavrnus Spatial Connector allows you to specify which UI to show both while the Space is Loading and once it is ready. We provide a few defaults (a Loading graphic, a Users Menu, and a Voice/Video Menu). You can modify/replace these and add your own at will. Loading Menus will, of course, be destroyed once the Space is connected.

Avatars and Co-Presence

Avatars in Cavrnus are driven by the same Properties logic that governs the rest of the Space. As such, any Avatar you want to use will need to, at a minimum, have a SyncTransform script on it or some other way of Binding/handling the “Transform” Property to show the User’s movement. The Unique Container Name can be left blank though, because it will be automatically filled in by our systems for each individual user when spawned. These avatars can also send & receive any other custom properties you want (User Color, Left Elbow Transform, etc).

To use a customized Avatar, simply drag & drop it into the Cavrnus Spatial Connector.

To send your Co-Presence to other users, select the Local User’s rig and hit Cavrnus->Set Selected Object As Local User.

This will automatically add a CavrnusLocalUserFlag to your character and a SyncTransform component to send your position across the wire. As with remote avatars you can send and receive as many custom properties as you would like. However, ensure that the Property Names match between the Local Rig and the Remote Avatar. If you are sending a property named “position” and their Remote User Avatar is listening for one named “transform”, you’re gonna have a bad time.

Spawnable Objects

If you want to spawn prefabs into your Scene at runtime, you will need to add them to the Spawnable Objects list at the bottom of the Cavrnus Spatial Connector. We offer a shortcut for this where you can right-click on the Prefab and select Cavrnus->Make Selection Spawnable.

The Unique Id is what is stored in the Journal as the thing being spawned. In theory, this means you could make changes to a prefab that already has Journal entries spawning its ID. This would mean anyone running with the new version of the application would see the new prefab get spawned in place of the old one.

Next Steps

At this point, hitting Play in Unity should Authenticate the user and place them in a Space, with all of the relevant UI being spawned in with them!

Now you can start synchronizing the various things inside your project!

You can do this by adding our No-Code Collaboration Components to automatically synchronize an object's Properties.

Alternatively, you can read up on more advanced techniques in our Developer Guide, or make calls directly using our API Reference.

Related pages