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
  • Sending network commands
  • General setup
  • In this scene...
  • Build and try

Was this helpful?

Export as PDF
  1. Tutorial project
  2. Start Tutorial

6. Network commands

Last updated 2 years ago

Was this helpful?

Sending network commands

This scene will show you how easy it is to set up Networking in your Unity project and send network commands to other Clients. Network commands are like sending direct messages to objects instead of syncing variable values.

In this example each Client has one character they can control with "click to move" input. They can right-click on another Entity to send a command and that Entity will instantiate an Exclamation mark above their head.

General setup

In the Hierarchy of the scene you can see three core Prefabs:

Coherence Entity is the Prefab that will change per scene with different functionality. It has a standard CharacterControllerand Rigidbody as well as an Agent script which will handle movement functionality through the Input Manager in the Core Scene Setup Prefab.

In this scene...

Coherence Entity can send commands to other entities through the Coherence Handler component. In the coherenceSync component we can open the bindings window and find a Methods tab used for command setup. There we can find a method called ReceiveCommand and beside it, an icon describing who the command will be sent to (only to the objects' authority or alternatively to all Clients).

In the game view in Play mode, commands can be sent to other Entities via the right click button. An exclamation mark asset will pop up above the right-clicked Entity for all Clients.

If we were to set this command to Authority Only then only the objects' authority would receive this method call.

Build and try

You can build this scene via the Build Settings. Run the local Replication Server through the Window > Coherence > Settings window and see how it works. You can try running multiple Clients rather than just two and see how replication works for each.

Core Scene Setup and Coherence Setup are present in all scenes and described in detail on page.

Start Tutorial