Colyseus Unity3d

MIT
by gamestdio

Multiplayer Game Client for Unity

( Crawled 31 minutes ago )
+

colyseus.js

Multiplayer Game Client for Unity.

Join the chat at https://gitter.im/gamestdio/colyseus Donate

C#/Unity client for Colyseus Multiplayer Game Server.

Installation

Copy Assets/Colyseus into your project. See usage example.

Running the demo server

Ensure you have Node v6+ installed. Then run these commands in your commandline:

cd Server
npm install
npm start

Usage

Client colyseus = new Colyseus.Client ("ws://localhost:2657");

Room room = colyseus.Join ("room_name");
room.OnUpdate += OnUpdate;

Getting the full room state

void OnUpdate (object sender, RoomUpdateEventArgs e)
{
    Debug.Log(e.state);
}

Listening to additions on state

room.state.Listen ("players", "add", OnAddPlayer);
void OnAddPlayer (string[] path, MessagePackObject value)
{
    Debug.Log ("OnAddPlayer");
    Debug.Log (value);
}

Listening to updates on state

room.state.Listen ("players/:id/:axis", "replace", OnPlayerMove);
void OnPlayerMove (string[] path, MessagePackObject value)
{
    Debug.Log ("OnPlayerMove");
    Debug.Log ("playerId: " + path[0] + ", axis: " + path[1]);
    Debug.Log (value);
}

Listening to deletions on state

room.state.Listen ("players/:id", "remove", OnPlayerRemoved);
void OnPlayerRemoved (string[] path, MessagePackObject value)
{
    Debug.Log ("OnPlayerRemoved");
    Debug.Log ("playerId: " + path[0]);
}

Building for Windows Store (Universal 10 / UWP)

Build steps for UWP:

  • rename Colyseus/MsgPack/MsgPack.dll to something like MsgPack2.dll.
  • rename Colyseus/MsgPack/MsgPackUWP.dll to MsgPack.dll

Otherwise, build process for Windows Store (Universal 10) will fail because the MsgPack-namespace can't be found. The Unity Player however should work as expected after this, despite the renaming.

License

MIT