fix alot of shit for webrtc to work
This commit is contained in:
166
NETWORK_MODE_GUIDE.md
Normal file
166
NETWORK_MODE_GUIDE.md
Normal file
@@ -0,0 +1,166 @@
|
||||
# Network Mode Selection Guide
|
||||
|
||||
## New Features
|
||||
|
||||
### 1. **Network Mode Dropdown** (PC Only)
|
||||
|
||||
On PC builds, you'll now see a dropdown in the main menu:
|
||||
- **ENet (PC/LAN)**: Traditional IP-based networking for PC players
|
||||
- **WebRTC (Browser/Web)**: Web-compatible networking using room codes
|
||||
|
||||
The dropdown is automatically hidden on web builds (WebRTC is auto-selected).
|
||||
|
||||
### 2. **--webrtc Command Line Flag**
|
||||
|
||||
Force WebRTC mode on PC builds:
|
||||
|
||||
```bash
|
||||
# Start as host with WebRTC
|
||||
godot --path . -- --host --webrtc
|
||||
|
||||
# Join with WebRTC
|
||||
godot --path . -- --join --webrtc --address=ABC123
|
||||
|
||||
# Example with room code
|
||||
godot --path . -- --join --webrtc --address=XYZ789
|
||||
```
|
||||
|
||||
## Usage Examples
|
||||
|
||||
### PC to PC (Same LAN) - ENet Mode
|
||||
|
||||
**PC 1 (Host):**
|
||||
1. Select "ENet (PC/LAN)" in dropdown
|
||||
2. Click "Host Game"
|
||||
3. Note your IP (e.g., 192.168.1.100)
|
||||
|
||||
**PC 2 (Join):**
|
||||
1. Select "ENet (PC/LAN)" in dropdown
|
||||
2. Enter host IP in "Server Address"
|
||||
3. Click "Join Game"
|
||||
|
||||
### PC to PC (Internet) - WebRTC Mode
|
||||
|
||||
**PC 1 (Host):**
|
||||
1. Select "WebRTC (Browser/Web)" in dropdown
|
||||
2. Click "Host Game"
|
||||
3. Share the 6-character room code (e.g., "ABC123")
|
||||
|
||||
**PC 2 (Join):**
|
||||
1. Select "WebRTC (Browser/Web)" in dropdown
|
||||
2. Enter room code in "Server Address"
|
||||
3. Click "Join Game"
|
||||
|
||||
### PC to Browser - WebRTC Mode
|
||||
|
||||
**PC (Host):**
|
||||
1. Select "WebRTC (Browser/Web)" in dropdown
|
||||
2. Click "Host Game"
|
||||
3. Share room code
|
||||
|
||||
**Browser (Join):**
|
||||
1. Enter room code (WebRTC auto-detected)
|
||||
2. Click "Join Game"
|
||||
|
||||
### Browser to Browser - WebRTC Mode
|
||||
|
||||
**Browser 1 (Host):**
|
||||
1. Click "Host Game"
|
||||
2. Share room code
|
||||
|
||||
**Browser 2 (Join):**
|
||||
1. Enter room code
|
||||
2. Click "Join Game"
|
||||
|
||||
## Command Line Examples
|
||||
|
||||
### Test with WebRTC
|
||||
|
||||
```bash
|
||||
# Terminal 1 - Host with WebRTC
|
||||
godot --path . -- --host --webrtc
|
||||
|
||||
# Terminal 2 - Join with WebRTC (room code from Terminal 1)
|
||||
godot --path . -- --join --webrtc --address=ABC123
|
||||
```
|
||||
|
||||
### Test with ENet (Default)
|
||||
|
||||
```bash
|
||||
# Terminal 1 - Host
|
||||
godot --path . -- --host
|
||||
|
||||
# Terminal 2 - Join
|
||||
godot --path . -- --join --address=127.0.0.1
|
||||
```
|
||||
|
||||
### Test with Multiple Local Players
|
||||
|
||||
```bash
|
||||
# Host with 2 local players using WebRTC
|
||||
godot --path . -- --host --webrtc --players=2
|
||||
|
||||
# Join with 2 local players
|
||||
godot --path . -- --join --webrtc --address=ABC123 --players=2
|
||||
```
|
||||
|
||||
## When to Use Each Mode
|
||||
|
||||
### Use **ENet** When:
|
||||
- Playing on same LAN (local network)
|
||||
- Both players are on PC (Windows/Linux/Mac)
|
||||
- You want lower latency
|
||||
- You have direct network access
|
||||
|
||||
### Use **WebRTC** When:
|
||||
- Playing over the internet (through NATs/firewalls)
|
||||
- Playing with browser users
|
||||
- Playing on mobile browsers
|
||||
- You want easy room code sharing (no IP addresses)
|
||||
|
||||
## Technical Details
|
||||
|
||||
### ENet
|
||||
- Protocol: UDP
|
||||
- Connection: Direct IP:Port
|
||||
- Latency: Lower (direct connection)
|
||||
- NAT Traversal: Requires port forwarding
|
||||
- Compatibility: PC only
|
||||
|
||||
### WebRTC
|
||||
- Protocol: UDP/DTLS via WebRTC
|
||||
- Connection: Room codes via signaling server
|
||||
- Latency: Slightly higher (STUN/relay)
|
||||
- NAT Traversal: Automatic (STUN/TURN)
|
||||
- Compatibility: PC, Browser, Mobile
|
||||
|
||||
### Your Servers
|
||||
- **Matchbox Signaling**: `ws://ruinborn.thefirstboss.com:3536`
|
||||
- **STUN Server**: `stun:ruinborn.thefirstboss.com:3578`
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
**Dropdown not visible:**
|
||||
- This is normal on web builds (WebRTC auto-selected)
|
||||
|
||||
**Can't connect in ENet mode:**
|
||||
- Check firewall (port 21212)
|
||||
- Verify IP address is correct
|
||||
- Try WebRTC mode instead
|
||||
|
||||
**Can't connect in WebRTC mode:**
|
||||
- Verify room code matches exactly
|
||||
- Check matchbox server is running
|
||||
- Try ENet mode for LAN play
|
||||
|
||||
**Room code not showing:**
|
||||
- Only shown in console when hosting with WebRTC
|
||||
- Will be displayed in UI in future updates
|
||||
|
||||
## Future Improvements
|
||||
|
||||
- [ ] Display room code in UI (not just console)
|
||||
- [ ] Copy room code to clipboard button
|
||||
- [ ] Lobby browser (see active rooms)
|
||||
- [ ] Remember last used network mode
|
||||
- [ ] Auto-detect best mode for connection
|
||||
Reference in New Issue
Block a user