LogoLogo
HomeOnline DashboardAPIDiscordForums
SDK 1.7 Preview
SDK 1.7 Preview
  • Welcome
  • Overview
    • Features
    • Roadmap
  • Getting started
    • Get the Unity SDK
    • Setup a project
      • 1. Scene setup
      • 2. Prefab setup
      • 3. Test your game locally
        • Local testing using builds
        • Local testing via Unity's Multiplayer Play Mode
        • Local testing via ParrelSync
      • 4. Test in the cloud
        • Deploy a Replication Server
        • Share builds
    • How to... ?
    • Single-player to multiplayer
    • Video tutorials
    • Samples and tutorials
      • Package samples
      • Sample Connection UIs
      • First Steps tutorial
        • 1. Basic syncing
          • 1.1 Animation parameters
          • 1.2 Sending commands
        • 2. Physics / Authority transfer
        • 3. Areas of interest
        • 4. Parenting entities
        • 5. Complex hierarchies
        • 6. Persistence
      • Campfire project
        • Game mechanics
        • Leveraging object pooling
        • Remote interactions: Chairs
        • Remote interactions: Trees
        • A unique object with complex state
        • Custom instantiation and destruction
        • Running a server-side NPC
        • Playing audio and particles
        • A simple text chat
      • Beginner's guide to networking
    • Troubleshooting
  • Manual
    • Unity Components
      • CoherenceSync
      • CoherenceBridge
      • CoherenceLiveQuery
      • CoherenceTagQuery
      • CoherenceGlobalQuery
      • CoherenceInput
      • CoherenceNode
      • PrefabSyncGroup
      • Order of execution
    • Networking state changes
      • Instantiate and Destroy Objects
      • Supported types
      • Messaging with Commands
      • Syncing child GameObjects
      • Animation
      • CoherenceSync references
      • [Sync] and [Command] Attributes
      • [OnValueSynced] Attribute
      • Creating your own syncable member
      • Custom Component Actions
      • Rigid Bodies
      • Interpolation
    • Authority
      • Authority transfer
      • Server-authoritative setup
    • Lifetime
      • Persistence
      • Uniqueness
      • Example: A global counter
    • Parenting network entities
      • Direct children CoherenceSyncs
      • Deeply-nested CoherenceSyncs
      • Nesting Prefabs at Edit time
    • Asset management
      • Instantiating from CoherenceSyncConfig
      • Instantiate via
      • Load via
    • Scene management
    • Multiple Connections within a Game Instance
    • Baking (code generation)
      • Conditional compilation
    • Replication Server
      • Rooms and Worlds
      • Replication Server API
    • Simulators (Servers)
      • Scripting: Client vs Simulator
      • Run local Simulators
      • World Simulators
      • Room Simulators
      • Advanced Simulator Authority
      • Simulator slugs
      • Build and Deploy
      • Command-line arguments
    • Client Connections
    • Optimization
      • Areas of Interest
      • Level of Detail (LOD)
      • Profiling
      • Simulation Frequency
    • Project Settings
    • Advanced topics
      • Big worlds
        • World Origin Shifting
        • Load balancing
      • Competitive games
        • Simulation Frame
        • Determinism, Prediction and Rollback
      • Team workflows
        • Version Control integration
        • Continuous Integration
      • Schema explained
        • Specification
        • Field settings
        • Archetypes
      • Code stripping
      • Replication Server CLI
      • Single-player gameplay
    • Scripting API
  • Hosting
    • Choosing where to host
    • coherence Cloud
      • Online Dashboard
      • Manage Worlds
      • Configure Rooms
      • Player Accounts
      • Game Services
        • Lobbies
        • Cloud Storage
        • Key-Value Store (Legacy)
      • APIs
        • Worlds
        • Rooms
        • Lobbies
        • Cloud Storage
        • Key-Value Store (Legacy)
    • Peer-to-peer
      • Implementing Client hosting
        • Steam Relay
        • Epic Online Services (EOS) Relay
        • Azure PlayFab Relay
  • Support
    • Release notes
    • Glossary
    • Unreal Engine support
    • WebGL support
    • ECS / DOTS support
    • Known issues
    • Upgrade guide
      • Upgrade 1.6 -> 1.7
      • Upgrade 1.5 -> 1.6
      • Upgrade 1.4 -> 1.5
      • Upgrade 1.3 -> 1.4
      • Upgrade 1.2 -> 1.3
      • Upgrade 1.1 -> 1.2
      • Upgrade 1.0 -> 1.1
      • Upgrade 0.10 -> 1.0
      • Upgrade 0.9 -> 0.10
    • Credit cost & pricing
    • Report a bug
Powered by GitBook
On this page
  • Composition, not inheritance
  • Sync what you already have
  • Instantiate and destroy as you usually would
  • One Prefab, both modes
  • RPCs without branching
  • Effortless bandwidth optimization
  • Hierarchy and physics that just work
  • Interpolation out-of-the-box
  • Quick iterations
  • Flexible topology
  • Give it a shot!

Was this helpful?

Export as PDF
  1. Getting started

Single-player to multiplayer

Was this helpful?

It is generally believed that converting an existing single-player game to multiplayer is next to impossible. At coherence, we've proven this wrong time and time again, porting projects small and big, from working proof of concept within days to finished, full-blown multiplayer within just a few months.

To understand how you can achieve this too, let's examine some of the unique coherence features that make it not only possible, but also fun!

Composition, not inheritance

coherence makes game objects networked by adding a CoherenceSync component, simple as that. There is no need to derive from a special "NetworkBehavior" class, which is especially painful when your project already has a base class for all in-game objects that provides some critical utilities.

Sync what you already have

Forget NetVars or custom serialization code. Syncing variables is super easy! No code required—choose what you want to sync, and you're good to go!

This makes the transition to multiplayer much smoother, as you do not have to rewrite the networked components and other parts of the codebase which rely on those synced members.

Instantiate and destroy as you usually would

No special calls like netManager.Instantiate() or netManager.Destroy() needed. We handle all the networking bits of the object lifetime behind the scenes so that you can focus on the fun stuff!

One Prefab, both modes

RPCs without branching

Whether online or offline, sending a command will have the same effect. Due to our Authority system, this works even if the command would normally be received by another Client—in single-player, you have the authority over all entities, and so the function will still be called. Neat!

CoherenceSync sync;

void Update()
{
    if (Input.GetKeyDown(KeyCode.Space))
    {
        // Works both in single-player and multiplayer
        sync.SendCommand(SpawnFireworks, MessageTarget.All, transform.position);
    }
}

public void SpawnFireworks(Vector3 position)
{
    Instantiate(FireworkPrefab, position, Quaternion.identity);
}

Effortless bandwidth optimization

Even if porting initially goes smoothly, you might soon discover that the game feels extremely laggy. This fabulous horde of zombies is using too much bandwidth; yikes! You're left with a choice - redesign the game to be less cool or spend precious hours on handcrafting bandwidth optimizations for your networked objects.

We give you a third choice—keep the game cool and optimize within minutes. Trim your floats, limit your ints, remove whole components for objects at a distance—all with just a few clicks in our network LODing system. You are in control of every single bit!

Hierarchy and physics that just work

Hierarchy and physics systems are key to most games made in Unity. They are also among the hardest elements to sync. We understand that and made sure that they "just work" in multiplayer.

Interpolation out-of-the-box

Even with the best netcode in the world, interpolation is what makes the difference between a smooth multiplayer experience and a choppy, rubber-banding slide show. We prefer the former, and thus, we provide you with a solid, yet flexible, state-of-the-art interpolation system.

While position, rotation, and scale are interpolated by default, you can enable interpolation for any synced variable with just one click. Choose between different forms of interpolation, tweak settings, or provide your own through a simple API.

Quick iterations

Testing multiplayer can be extremely time-consuming, especially if it requires building a game client. Being mindful of this, we've made coherence compatible with ParrelSync and Multiplayer Play Mode - the two solutions that let you run multiple editor instances of your project, so you can skip the build process.

If that's not fast enough for you, we also made it possible to run multiple clients from within the same Unity editor - how cool is that?

Flexible topology

Games have different networking needs. Coop games are usually played with friends and rarely need cheat prevention. Some games require cross-play, and others need persistent, cheat-proof worlds hosted on game servers.

We handle all those cases. coherence doesn't force you into a single networking topology. Better yet, due to our flexible Authority system, you can very easily switch between them.

Why overspend on servers early if you can start with our free P2P option, test the waters, and move to a more secure option at any point? There really is no reason.

Give it a shot!

You're now ready to tackle your first try at networking your game with coherence. We have all the tutorials and resources you need, as videos or interactive step-by-step demos, whichever you prefer. Good luck!

Due to our flexible system, you can choose what should happen when a given component is used in multiplayer. This makes it trivial to reuse the same Prefab in both single-player and multiplayer modes. Got a PlayerController, which should be enabled only for local players? Easy-peasy. Need a RigidBody to be kinematic on the remote player? No problem!

Component Actions