Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by ChristianTellefsen

Hi,

I'm looking into using Impact for a multiplayer game.

Has anyone else used tried using Impact with an authorative nodejs server? Since the Impact engine doesn't run directly on the server out of the box, I'm looking into the following solutions:

1. Implement a parallel server implementation of the impact physics. Basically, make Server versions of entity / collision with the data needed (like acc, pos, vel), and notify the client whenever anything interesting happens. This has the disadvantage of requiring parallel implementations of a lot of code, which would then have to be kept up to date when upgrading impact. Also, parallel code is a good source of hard to find bugs...

2. Make a mock client environment for the full Impact engine to run in on the server (like mock window, document...) Has anyone had any success doing something like this? I kind of think this might be the most elegant solution, since it requires no re-implementation of client code on the server.

3. Decouple the physics simulation in the client, and use the decoupled simulation in the server as well. This requires forking impact and changing the provided impact files, which has the disadvantage of making it harder to update the engine later.

What do you think? What's the best way to do this? I'm especially interested in hearing if someone has actually succeeded in making an authorative nodejs server for Impact!

Cheers,
Christian.

1 decade ago by dotnetprodev

I have not tried it yet, but you might look into impsock. It is a socket.io implementation for impactjs.

https://github.com/elbowdonkey/impsock

1 decade ago by SlouchCouch

I haven't implemented it but i've thought about implementing it. It seems like a lofty undertaking but not impossible.

I'd guess that your option 2 is probably the best. in multiplayer the server version of the "game" being played should probably be considered your source of truth. Have physics and drawing running on each client, and have a physics update fire off every so often (once a second? I dunno) or during major events like.

I wish you luck on your lofty undertaking, but html5 multiplayer might be the next evolution in html5 games.

1 decade ago by dotnetprodev

Implementable socket server with NodeJS and Socket.IO is relatively easy.

Write a separate server api using sockets to send/receive player locations and status. I don't think you should try to include impact on the server. Just write the server part from scratch.

There are a ton of examples on the net on this topic.

1 decade ago by ChristianTellefsen

I'm sorry, I left out some details. I already have nodejs + socket.io + impact up and running, so I can run a multiplayer game just fine, just not with an authorative server.

I do not want a separate model of the world / ruleset on the client and server. The easiest to maintain long-term solution is to run the same simulation on the client and server, on the same data structure, using the same code. Of course, in a production system there would be specific server optimizations, but it's not important to me at this stage.

I had missed that impactjs also works with box2d. I guess that means that I can run box2d on the server instead, which solves part of the problem, though I still would need some way of keeping track of the entities and level collision.

1 decade ago by Ptg

Yep, have a look at my post in the code forum, I created a library to do exactly what you speak of:

http://impactjs.com/forums/code/impactjs-emulation-layer-for-node-js-use-modules-and-classes-on-both-client-and-server
Page 1 of 1
« first « previous next › last »