API reference
API reference
Select your platform
No SDKs available
No versions available

LocalMatchmaking Class

Extends MonoBehaviour
This class provides a ready-to-use encapsulation that leverages the OVRColocationSession APIs to host and discover local / nearby Colocation sessions and join them via Bluetooth and WiFi.
Comparing to networking framework based matchmaking: this workflow ensures users are all locally nearby, and there's no need for using Oculus user ids when colocating within the group (this requires working together with the Colocation block with the "Use Colocation Session" option enabled).
All players wish to participate in the same session need to have Bluetooth enabled and join the same WiFi network.
As the local session provided by OVRColocationSession is just a mechanism to find nearby players and send limited metadata for matchmaking, it doesn't really allow synchronizing networked objects and support multiplayer game logic. Hence, for the benefit of bootstrapping a local multiplayer session easily, this implementation also depends on the CustomMatchmaking block to create and join networked rooms provided by 3p networking frameworks (such as Photon Fusion2, Unity Netcode for GameObjects).
This class provides an automatic mechanism to host/join local sessions on Start() depending on whether an existing colocation sessions available.
For more information about the OVRColocationSession API, checkout the official documentation
If wish to explicitly host / join the session with own game UI, developers could also use several async functions provided to trigger manually.

Public Statics

Event to notify when a colocation session has been created and advertised successfully by the host.
Guid: group uuid that can be used to share anchors via OVRSpatialAnchor.ShareAsync
Event to notify when failed to create and advertise the colocation session.
string: failure reason, could be potentially used to display instruction to users
Event to notify when a colocation session has been discovered successfully by the guest.
Guid: group uuid that can be used to retrieve anchors via OVRSpatialAnchor.LoadUnboundSharedAnchorsAsync
Event to notify when failed to discover the colocation session.
string: failure reason, could be potentially used to display instruction to users

Member Functions

Manually start as host, this will create a networked room under the hood by CustomMatchmaking, and in turn this class listens for the networked room creation event then broadcast the room information via the OVRColocationSession API.
Manually start as guest, this will discover colocation sessions via the OVRColocationSession API, then stop after timeDiscoveringInSec if setting stopAfterTimeout is set to true.
Parameters
stopAfterTimeout
Boolean to determine whether to automatically stop the discovery after timeDiscoveringInSec

Static Member Functions

Wraps around the OVRColocationSession function to start advertise the colocation session with the byte data.
The public events of OnSessionCreateSucceeded and OnSessionCreateFailed will be notified accordingly.
Parameters
data
metadata that's included in the advertisement, could pass up to OVRColocationSession.Data.MaxMetadataSize bytes.
Wraps around the OVRColocationSession function to stop advertise the local session.
Wraps around the OVRColocationSession function to start discovering local sessions with custom callback.
The public events of OnSessionDiscoverSucceeded and OnSessionDiscoverFailed will be notified accordingly.
Parameters
onGroupFound
Custom callback to parse the data received from the local session advertisement.
Wraps around the OVRColocationSession function to stop discovering the local session.
Parameters
onGroupFound
Custom callback to remove from the discovery subscription.
Did you find this page helpful?
Thumbs up icon
Thumbs down icon