/MLAPI-Demo

A simple project that uses MLAPI 0.1.0 and SteamP2P transport to connect.

Primary LanguageC#MIT LicenseMIT

MLAPI-Demo

A simple project that use MLAPI and its Steam transport with basic connection function and few RPC calls for demo purpose.

Tested Environment

Prerequisites

  • Make sure Steam is running on the background.
  • Use another PC/Mac with another Steam account to test connection.

UI

Menu

Screenshot 1 - Menu In menu scrren, here you can:

  • Host a room.
  • Join a public room.
  • Join a friend room.

Host / Client

Screenshot 2 - Host Show only after connected as host or client, here you can:

  • Invite a friend to the room.
  • Execute the RPC events on different objects.

Prefabs

There are 3 prefabs for different demo purposes:

  • MultiplayerDemoPlayer: The player prefab, each client has its own one.
  • MultiplayerDemoSceneObject: An object spawned with the scene, MLAPI reference them using soft-sync, owned by host.
  • MultiplayerDemoSpawnedObject: An object spawned after connection, owned by host.

RPC Calls

Each prefab contains a RPC calls as:

  • OnSyncClick(): Called on clicking the button, execute either SyncServerRpc or SyncClientRpc.
  • SyncServerRpc(): Called from client to server only.
  • SyncClientRpc(): Called from server to client only.

Network Variable

Each prefab contains a NetworkVariableInt and change it every 30s. Their value can be checked on Editor inspector. This demostrates how MLAPI sync value automatically.

Voice Chat

This demo uses Steam Voice to detect and send voice. It may not be as good as other paid voice chat solution, but it's free and good enough for most game. See MultiplayerDemoPlayer.cs for more details.