LogoLogo
⚠️ Outdated documentationGo to LatestHomeAPI
SDK 0.9
SDK 0.9
  • Welcome
  • Overview
    • What is coherence?
    • How does coherence work?
    • Features and Roadmap
    • Rooms and Worlds
    • Requirements
    • Release Notes
  • Get Started
    • Install coherence
    • Scene setup
    • Prefab setup
    • Baking and code generation
    • Build and run
    • Create a free account
    • Deploy Replication Server
    • Share builds
    • Troubleshooting
  • Authority and communication
    • How authority works
    • Authority transfer
    • Commands
    • Simulation frame
    • Client connections
    • Server-authoritative setup
    • GGPO
    • Animations
    • Value sync callbacks
  • Persistence
    • Overview
    • Configuring persistence
    • Storage
    • Example – a global counter
  • Optimization
    • Overview
    • Simulation frequency
    • Areas of interest
    • Level of detail
    • Interpolation
  • Connected entities
    • Overview
    • Entity references
    • Parent-child relationships
    • CoherenceNode
  • Simulators
    • Overview
    • Client vs Simulator logic
    • Build and deploy
    • Simulator load balancing
    • Room Simulators
    • Multi-Room Simulators (advanced)
    • World Simulators
    • Simulator slugs
    • Testing Simulators locally
  • Tutorial project
    • Get the Tutorial Project
    • Start Tutorial
      • 1. Transforms
      • 2. Physics
      • 3. Persistence
      • 4. Animation and variables
      • 5. AI navigation
      • 6. Network commands
      • 7. Team-based
      • 8. Connected Entities
  • Game Services
    • Game account
    • Key-value store
    • Matchmaking
  • Developer Portal
    • Overview
    • Dashboard
    • Enabling game services
    • Configure Rooms
    • Manage Worlds
  • API reference
    • coherence SDK
      • CoherenceSync
      • MonoBridge
      • LiveQuery
      • Level of detail
      • Sample UI
      • Settings window
      • Custom bindings (advanced)
      • PlayResolver
      • Rooms
      • Worlds
    • Cloud API
      • API tokens and keys
      • Game account
      • Key-value store
      • Matchmaking
    • Replication Server
    • Simulation Server
  • Schema reference
    • Overview
    • Specification
    • Field settings
    • Archetypes in schemas
  • Resources
    • Downloads
    • SDK update guide
    • Video tutorials
    • Order of execution
    • Glossary
    • CLI utilities
    • Simulator CLI arguments
    • Helper scripts
    • Troubleshooting
    • Continuous Integration setup
  • Community
    • Community
  • Additional information
    • Pricing
    • SLA
    • Unreal Engine support
    • WebGL
    • Peer-to-Peer (P2P)
Powered by GitBook
On this page

Was this helpful?

Export as PDF
  1. API reference
  2. coherence SDK

Worlds

Last updated 2 years ago

Was this helpful?

Worlds API

Worlds functionality can also be accessed through the PlayResolver just like rooms. Worlds work a differently however and are a bit simpler.

Worlds

First we need to fetch the available Worlds. Unlike Rooms, Worlds cannot be created by a Client and need to be setup in the Developer Portal.

async Task<(IReadOnlyList<WorldData>, bool)> FetchWorlds()

FetchWorlds in PlayResolver.cs allows us to fetch the available Worlds for our project. This task returns a list of Worlds in the form of WorldsData objects and a boolean that indicates if the operation was successful.

This method also calls EnsurePlayConnection which initializes the needed mechanisms in thePlayResolver if necessary. EnsurePlayConnection can also be called directly for initialization.

async Task<WorldData> FetchLocalWorld()

FetchLocalWorld in PlayResolver.cs returns the local World for a local running World Server.

The WorldsConnectDialog populates a dropdown with the Worlds returned by both of these methods so we can select a World.

After we've selected a World we can connect to it using:

void JoinWorld(IClient client, WorldData data, bool isSimulator = false)

JoinWorld in PlayResolver.cs connects the Client that we pass to the method to the World we pass to the method.

The isSimulator optional parameter is used for Simulators and can be ignored for regular Client connections (see ).

The WorldsConnectDialog is an example implementation for Worlds usage.

When connected to a Room or a World, the Client can access the currently connected endpoint by accessing the Coherence.IClient.LastEndpointData property of the CoherenceMonoBridge, e.g. myBridge.Client.LastEndpointData.

Simulators