Could I use the Blender Game Engine, Python, and Python's sockets
module (internet data/communication module) to make a multiplayer Blender game?
-
1$\begingroup$ Check this out: youtube.com/watch?v=WIOn4r54l44 $\endgroup$– agiroCommented Jan 17, 2018 at 21:48
-
$\begingroup$ There's an addon which adds multiplayer support which may be what you're looking for: blenderartists.org/forum/… $\endgroup$– BrenticusCommented Jan 17, 2018 at 21:53
1 Answer
Yes, you can.
Game aspect
You can use any Python network library (such as socket) to send and receive data. The BGE itself does not have a build-in network system.
Access method
I suggest to use a non-blocking polling operation. This means your python code asks the connection for the data received since the last run and applies it to the scene. When no data was received ... do not wait for data as this will block your game.
Threading
Avoid the usage of threads (as you often see in examples). This can cause conflicts inside the BGE game loop. Just Implement the inner code of the thread loop as a script.
Network business
The sole transfer of data (connecting, reading and writing) is pretty simple. The most work needs the business around that.
When to connect?
When to send what?
When to expect what kind of data in what format?
This strongly depends on your game.
Be aware you should think about:
- Where to get the servers IP address?
- How to authenticate a client?
- How to create a lobby to bring the players together?
- How to start a game session with known clients?
- How do the participants of a game session communicate with each other?