Open maticstric opened 6 months ago
Bump
@maticstric please don't bump issues without adding more information.
Opening issues in random maintainers repositories is also very impolite.
This is mostly a documentation issue (we could add some extra checks in code to throw an error).
The ENetConnection.service
function should not be called when using the ENetMultiplayerPeer, since that is used internally by ENetMultiplayerPeer.poll()
and calling it manually will prevent the multiplayer peer from working correctly.
My bad.
The documentation for using Godot multiplayer without its "High-level multiplayer" features is pretty much non-existent, so I felt I didn't have a good way forward. Had to spend a few days looking at source code to figure out what I'm supposed to do. Still not sure if I totally get it, but ENetConnection
seems to be the important class. It would be nice to mention this somewhere or maybe have a simple example project. There don't even seem to be random online (blog, youtube, etc.) tutorials for this.
For a beginner to Godot multiplayer it's very hard to keep track of the differences between the many ENet/Multiplayer classes in Godot (MultiplayerAPI, ENetMultiplayerPeer, MultiplayerPeer, PacketPeer, ENetConnection, ENetPacketPeer, etc.).
Thanks for the help!
Tested versions
System information
MacOS 12.5 - Godot v4.2.stable.official
Issue description
The
service()
function should return anEVENT_CONNECT
when a new player connects. This works if I simply create anENetMultiplayerPeer
andcreate_server
orcreate_client
, however, as soon as I set themultiplayer.multiplayer_peer
variable to this newly createdENetMultiplayerPeer
, theservice()
function no longer returns any non-zero events.Steps to reproduce
Open the MRP. Set the project to open two instances (Debug -> Run Multiple Instances -> Run 2 Instances). Run the project. Click the host button on one instance and then join on the other. You would expect some prints (two since there's two connections), but nothing happens.
I also have some commented lines to show that it does work as long as I don't set the
multiplayer.multiplayer_peer
variable. Uncomment line 12. Comment lines 13, 22, and 30. Again, run project and click host and join. You should see some printouts from the non-zero event (print on line 16).Minimal reproduction project (MRP)
demo.zip