Coder Social home page Coder Social logo

naveen-agula / colyseus-unity3d Goto Github PK

View Code? Open in Web Editor NEW

This project forked from colyseus/colyseus-unity-sdk

0.0 2.0 0.0 1.12 MB

⚔ Multiplayer Game Client for Unity

Home Page: https://colyseus.io

License: MIT License

C# 99.51% JavaScript 0.49%

colyseus-unity3d's Introduction



Patreon donate button Discussion forum

Multiplayer Game Client for Unity.
View documentation

Installation

Copy Assets/Plugins into your Unity project.

Running the demo server

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

cd Server
npm install
npm start

Usage

You'll need to start a coroutine for each WebSocket connection with the server. See usage example for more details.

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

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

Getting the full room state

void OnStateChange (object sender, RoomUpdateEventArgs e)
{
	if (e.isFirstState) {
		// First setup of your client state
		Debug.Log(e.state);
	} else {
		// Further updates on your client state
		Debug.Log(e.state);
	}
}

Listening to add/remove on a specific key on the room state

room.Listen ("players/:id", OnPlayerChange);
void OnPlayerChange (DataChange change)
{
	Debug.Log (change.path["id"]);
	Debug.Log (change.operation); // "add" or "remove"
	Debug.Log (change.value); // the player object
}

Listening to specific data changes in the state

room.Listen ("players/:id/:axis", OnPlayerMove);
void OnPlayerMove (DataChange change)
{
	Debug.Log ("OnPlayerMove");
	Debug.Log ("playerId: " + change.path["id"] + ", axis: " + change.path["axis"]);
	Debug.Log (change.value);
}

License

MIT

colyseus-unity3d's People

Contributors

endel avatar wenish avatar bhavik66 avatar seismic-cbrooks avatar kodypeterson avatar niklaswolf avatar

Watchers

James Cloos avatar naveen.agula avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.