243 lines
5.0 KiB
Markdown
243 lines
5.0 KiB
Markdown
# Multiplayer Testing Guide
|
||
|
||
## Quick Automated Testing
|
||
|
||
I've created easy testing scripts for you!
|
||
|
||
### Windows
|
||
|
||
**Option 1: Use the Batch Script**
|
||
```bash
|
||
# Edit TEST_MULTIPLAYER.bat and set your Godot path
|
||
# Then just double-click it or run:
|
||
TEST_MULTIPLAYER.bat
|
||
```
|
||
|
||
**Option 2: Manual Command**
|
||
```bash
|
||
# Terminal 1 (Host)
|
||
"C:\Program Files\Godot\godot.exe" --path "C:\dev\godot\multiplayer-coop" -- --host
|
||
|
||
# Terminal 2 (Client 1)
|
||
"C:\Program Files\Godot\godot.exe" --path "C:\dev\godot\multiplayer-coop" -- --join
|
||
|
||
# Terminal 3 (Client 2)
|
||
"C:\Program Files\Godot\godot.exe" --path "C:\dev\godot\multiplayer-coop" -- --join
|
||
```
|
||
|
||
### Linux/Mac
|
||
|
||
**Option 1: Use the Shell Script**
|
||
```bash
|
||
# Make it executable (already done)
|
||
chmod +x TEST_MULTIPLAYER.sh
|
||
|
||
# Run it
|
||
./TEST_MULTIPLAYER.sh
|
||
```
|
||
|
||
**Option 2: Manual Command**
|
||
```bash
|
||
# Terminal 1 (Host)
|
||
godot --path "$(pwd)" -- --host
|
||
|
||
# Terminal 2 (Client 1)
|
||
godot --path "$(pwd)" -- --join
|
||
|
||
# Terminal 3 (Client 2)
|
||
godot --path "$(pwd)" -- --join
|
||
```
|
||
|
||
## Command-Line Arguments
|
||
|
||
### Basic Arguments
|
||
|
||
- `--host` - Automatically start as host
|
||
- `--join` - Automatically join game
|
||
- `--address=IP` - Server address (default: 127.0.0.1)
|
||
- `--players=N` - Number of local players (default: 1)
|
||
|
||
### Examples
|
||
|
||
**Host with 2 local players:**
|
||
```bash
|
||
godot --path "path/to/project" -- --host --players=2
|
||
```
|
||
|
||
**Join specific server with 1 player:**
|
||
```bash
|
||
godot --path "path/to/project" -- --join --address=192.168.1.100
|
||
```
|
||
|
||
**Join with 3 local players:**
|
||
```bash
|
||
godot --path "path/to/project" -- --join --players=3
|
||
```
|
||
|
||
## Testing Scenarios
|
||
|
||
### Scenario 1: Simple 1v1
|
||
```bash
|
||
# Instance 1
|
||
godot -- --host
|
||
|
||
# Instance 2
|
||
godot -- --join
|
||
```
|
||
|
||
### Scenario 2: 1 Host + 2 Clients
|
||
```bash
|
||
# Instance 1
|
||
godot -- --host
|
||
|
||
# Instance 2
|
||
godot -- --join
|
||
|
||
# Instance 3
|
||
godot -- --join
|
||
```
|
||
|
||
### Scenario 3: Multiple Local Players
|
||
```bash
|
||
# Instance 1 (host with 2 local players)
|
||
godot -- --host --players=2
|
||
|
||
# Instance 2 (client with 2 local players)
|
||
godot -- --join --players=2
|
||
```
|
||
|
||
### Scenario 4: Maximum Chaos
|
||
```bash
|
||
# Instance 1 (host with 4 local players)
|
||
godot -- --host --players=4
|
||
|
||
# Instance 2-7 (each with 4 local players)
|
||
godot -- --join --players=4
|
||
```
|
||
Result: 8 machines × 4 local players = 32 total players!
|
||
|
||
## From Godot Editor
|
||
|
||
You can also test from the editor:
|
||
|
||
1. **Run the main instance from editor:**
|
||
- Just press F5 normally
|
||
- Host or join manually from the menu
|
||
|
||
2. **Run additional instances:**
|
||
```bash
|
||
# From terminal, run additional instances
|
||
godot --path "C:\dev\godot\multiplayer-coop" -- --join
|
||
```
|
||
|
||
## Troubleshooting
|
||
|
||
### "Connection Failed"
|
||
- Make sure host is running first
|
||
- Wait 1-2 seconds after starting host
|
||
- Check firewall settings
|
||
|
||
### "Can't find godot.exe"
|
||
- Edit the .bat or .sh script
|
||
- Set the correct path to your Godot executable
|
||
- On Linux/Mac, make sure `godot` is in your PATH
|
||
|
||
### "Players not spawning"
|
||
- Check the console/Output tab for errors
|
||
- Verify NetworkManager is loaded
|
||
- Make sure you're using matching project versions
|
||
|
||
### "Script won't run"
|
||
- Windows: Right-click .bat → Run as Administrator
|
||
- Linux/Mac: Make sure it's executable (`chmod +x TEST_MULTIPLAYER.sh`)
|
||
|
||
## What You Should See
|
||
|
||
### When Testing Works:
|
||
1. **Host window** opens, immediately shows game world
|
||
2. **Client 1** opens, connects, spawns in game world
|
||
3. **Client 2** opens, connects, spawns in game world
|
||
4. All players visible to each other
|
||
5. All players can move and interact
|
||
|
||
### Debugging
|
||
- Press **ESC** in any instance to see debug overlay
|
||
- Shows network status, peer ID, player counts
|
||
- Check Output tab in Godot for connection logs
|
||
|
||
## Performance Testing
|
||
|
||
### Test Network Sync
|
||
1. Start host + 2 clients
|
||
2. Move players around
|
||
3. Grab objects
|
||
4. Throw objects
|
||
5. Verify smooth sync (no jittering)
|
||
|
||
### Test Stress
|
||
1. Start multiple instances
|
||
2. Add many local players
|
||
3. Spawn many objects
|
||
4. Test with rapid interactions
|
||
5. Monitor FPS (press ESC for debug)
|
||
|
||
## Batch Testing Tips
|
||
|
||
### Quick Restart
|
||
```bash
|
||
# Windows: Create restart.bat
|
||
@echo off
|
||
taskkill /F /IM godot.exe
|
||
timeout /t 1 /nobreak
|
||
call TEST_MULTIPLAYER.bat
|
||
```
|
||
|
||
### Different Configurations
|
||
```bash
|
||
# Test different player counts
|
||
godot -- --host --players=1
|
||
godot -- --join --players=2
|
||
godot -- --join --players=3
|
||
godot -- --join --players=4
|
||
```
|
||
|
||
### Network Testing
|
||
```bash
|
||
# Test over network (replace IP with actual host IP)
|
||
godot -- --host # On machine 1
|
||
godot -- --join --address=192.168.1.100 # On machine 2
|
||
```
|
||
|
||
## CI/CD Testing
|
||
|
||
You can integrate these commands into automated testing:
|
||
|
||
```bash
|
||
# Start host in background
|
||
godot --path "$PROJECT" -- --host &
|
||
HOST_PID=$!
|
||
|
||
sleep 2
|
||
|
||
# Start client
|
||
godot --path "$PROJECT" -- --join &
|
||
CLIENT_PID=$!
|
||
|
||
# Wait and cleanup
|
||
sleep 10
|
||
kill $HOST_PID $CLIENT_PID
|
||
```
|
||
|
||
## Summary
|
||
|
||
✅ **Easiest**: Just run `TEST_MULTIPLAYER.bat` (Windows) or `./TEST_MULTIPLAYER.sh` (Linux/Mac)
|
||
|
||
✅ **Custom**: Use command-line arguments for specific scenarios
|
||
|
||
✅ **Flexible**: Combine with editor for debugging
|
||
|
||
✅ **Fast**: No clicking through menus, instant testing!
|
||
|
||
Happy testing! 🎮
|
||
|