A simple project that use MLAPI and its Steam transport with basic connection function and few RPC calls for demo purpose.
- Windows 10 19042.867 / macOS 11.2.3
- Unity 2019.4.18f1
- MLAPI 0.1.0 preview
- SteamP2P Transport 1.0.0
- Make sure Steam is running on the background.
- Use another PC/Mac with another Steam account to test connection.
- Host a room.
- Join a public room.
- Join a friend room.
Show only after connected as host or client, here you can:
- Invite a friend to the room.
- Execute the RPC events on different objects.
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.
Each prefab contains a RPC calls as:
OnSyncClick()
: Called on clicking the button, execute eitherSyncServerRpc
orSyncClientRpc
.SyncServerRpc()
: Called from client to server only.SyncClientRpc()
: Called from server to client only.
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.
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.