Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marcospb19/godot-enet-packet-server-example
Minimal example on how to setup a raw-packet `ENet` client and server in Godot 4.2
https://github.com/marcospb19/godot-enet-packet-server-example
enet godot multiplayer network tutorial
Last synced: about 2 months ago
JSON representation
Minimal example on how to setup a raw-packet `ENet` client and server in Godot 4.2
- Host: GitHub
- URL: https://github.com/marcospb19/godot-enet-packet-server-example
- Owner: marcospb19
- Created: 2024-07-06T23:25:42.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-07-07T00:58:41.000Z (7 months ago)
- Last Synced: 2024-10-15T22:10:44.373Z (3 months ago)
- Topics: enet, godot, multiplayer, network, tutorial
- Language: GDScript
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `ENet` raw packet server/client example
A tiny code example to show how to setup `ENet` server and clients for raw packets.
- Godot 4.2.
- Clients can only speak directly to the server.
- Server broadcasts messages to everyone.
- Clients receive a signal when other peers connect.## Disclaimers:
- Raw packets aren't the recommended way of handling game state.
- Unless you have a specific reason to use raw packets, try these first:
- [`@rpc`](https://docs.godotengine.org/en/4.2/tutorials/networking/high_level_multiplayer.html#remote-procedure-calls)
- [`MultiplayerSynchronizer`](https://docs.godotengine.org/en/stable/classes/class_multiplayersynchronizer.html)
- [`MultiplayerSpawner`](https://docs.godotengine.org/en/stable/classes/class_multiplayerspawner.html)
- No encryption.
- No authorization.
- No port forwarding.## How to run
Download and open the project in Godot 4.2:
```sh
git clone https://github.com/marcospb19/godot-enet-packet-server-example
cd godot-enet-packet-server-example
godot -e &> /dev/null & disown
```Set it to run multiple instances:
Press play (F5 hotkey), it should open 4 windows:
Start clicking on buttons and you'll see logs inside of the Godot editor.
```ruby
peer 2000: connected to peer 1
peer 1 : connected to peer 2000
peer 3000: connected to peer 1
peer 3000: connected to peer 2000
peer 1 : connected to peer 3000
peer 2000: connected to peer 3000
peer 1 : received msg from peer 3000: 'Hi from 3000'
peer 2000: received msg from peer 3000: 'Hi from 3000'
peer 3000: connected to peer 4000
peer 1 : connected to peer 4000
peer 4000: connected to peer 1
peer 4000: connected to peer 2000
peer 4000: connected to peer 3000
peer 2000: connected to peer 4000
peer 3000: received msg from peer 4000: 'Hi from 4000'
peer 1 : received msg from peer 4000: 'Hi from 4000'
peer 2000: received msg from peer 4000: 'Hi from 4000'
peer 3000: received msg from peer 2000: 'Hi from 2000'
peer 1 : received msg from peer 2000: 'Hi from 2000'
peer 4000: received msg from peer 2000: 'Hi from 2000'
```(IDs are random, I edited the above for better readability).
## More docs?
My plan is to put some of these into the docs, there are no official docs that put together an example like this.
## Open questions:
1. Is this, by default, using `ENet`'s reliable mode?
2. How hard is to change this from `Enet` to `WebRTC` or `WS`?## Can I copy this?
Yeah! That's the spirit!