I am thinking of making a game with Blender game engine for my project since I can use python in it. Is it possible to do multiplayer with python and bge?
Turn on thread page Beta
Computing Project watch
- Thread Starter
- 13-03-2018 20:35
- 13-03-2018 20:38
- 13-03-2018 21:06
Almost certainly - it's highly unlikely that there would be anything in Blender game engine, nor any other library or framework which would actively prevent you from working with network messages to/from other hosts or a server.
It looks like the Blender game engine helps you build all kinds of real-time 3D apps/games, but Networking is an entirely separate problem and separate concern to this.
I can't tell whether the Blender game engine has any of its own networking or client/server libraries - a quick google suggests that no such thing exists, but that other people have solved the problem by writing their own, so it seems like you'd need to do the same.
If you end up working with your own messaging system, the fact you're working with a realtime simulation means you'll likely need to consider running that in a separate thread (handling network sockets directly on a real-time game or simulation loop thread is usually a very bad idea!), so you'd also need to consider synchronisation between the realtime game/app, and any received network messages - You could consider using the queue class for this https://docs.python.org/3/library/queue.html
If you want to save yourself some work and learn a neat networking library, then you could take a look at ZeroMQ - it'll probably be easier than trying to fuss around with raw sockets. (Client/Server example using the Python "zmq" library - http://zguide.zeromq.org/py:all#The-...Server-Pattern ) - you'll need to install the zmq package to use it.
And for a simple way of creating messages to send/receive, have a look at pickle: https://docs.python.org/3/library/pickle.html
I'd suggest creating an entirely separate prototype app to play around with ZeroMQ (or raw sockets if that's what you'd prefer to use) and Pickle before trying to mix it up with your game.Last edited by winterscoming; 13-03-2018 at 22:06.