A multiplayer physics-based arena shooter built from scratch to learn network game programming. Features custom UDP networking, client-side prediction, input reliability, and smooth interpolation—all implemented without using pre-built networking frameworks.
Unity 6 | Server-Authoritative | UDP Networking | 2-4 Players
Educational project demonstrating production-grade network game programming concepts:
- 🌐 Custom UDP client-server architecture
- ⚡ Client-side prediction with server reconciliation
- 🔄 Automatic input retransmission (0% loss at 30% packet loss)
- 🎯 60 FPS remote player interpolation
- 🎨 Cute chibi characters with charge-to-shoot combat
Core Mechanic: Hold Space for 0-2 seconds to charge your shot—longer charge = longer range, higher arc, faster projectile.
-
Clone & Open in Unity 6
git clone https://github.com/yourusername/NetworkGameSession.git cd "Loving Away/Loving Away(Network Game)"
Open in Unity Hub (version 6000.2.6f1)
-
Run Local Test
- Press Play in Unity Editor
- Choose "Host Server" in connection dialog
- Controls: WASD (move), Space (charge/shoot), Tab (debug UI)
-
Multiplayer Test
- Build executable (File → Build Settings)
- Run Editor as server, Build as client
- Enter server IP in connection dialog
- Charge-to-Shoot: Variable range (5-20u), arc height (2-6u), speed (8-12 u/s)
- Health System: 5 HP, 1 damage per hit, color-coded health bars
- Knockback Physics: Projectiles push players toward arena boundary
- Death & Respawn: Instant death at boundary or 0 HP → 3 second respawn
- UDP Sockets: Custom implementation, 20 Hz server tick, 30 Hz client send
- Binary Serialization: Efficient protocol (22-82 bytes per message)
- Piggybacked ACKs: Input acknowledgments in state updates (Lab 8)
- Input Redundancy: Automatic retransmission within 100ms (Lab 8)
- Interpolation: Smooth 60 FPS rendering from 20 Hz snapshots (Lab 9)
- Client Prediction: Instant local response with blend reconciliation (Lab 9)
- ✅ 0% input loss at 30% packet loss (tested)
- ✅ 58-60 FPS with 4 players
- ✅ 14 Kbps bandwidth per client
- ✅ <50ms input latency
📄 Project Overview - 3-page summary with architecture, testing, and file guide
📄 Deliverable 5 Overview - Full technical report (7,500 words) 📄 Session 6 Summary - Implementation notes for Labs 8-9
📄 Project Status - Real-time progress tracking
NetworkGameSession/
├── Loving Away/
│ └── Loving Away(Network Game)/ # Main Unity project
│ └── Assets/Scripts/
│ ├── Network/ # UDP, serialization, ACKs, interpolation
│ │ ├── NetworkProtocol.cs
│ │ ├── GameNetworkManager.cs
│ │ ├── InputHistoryBuffer.cs # Lab 8: Retransmission
│ │ └── SnapshotBuffer.cs # Lab 9: Interpolation
│ ├── Gameplay/ # Server logic, player control
│ │ ├── ServerGameState.cs # Server-authoritative
│ │ └── SimplePlayerController.cs # Client prediction
│ └── UI/
│ └── ConnectionUI.cs # IP/port dialog
└── Docs/
├── Deliverable 5/ # Final deliverable (Labs 8-9)
└── Workflow/ # Development tracking
| Message | Size | Purpose |
|---|---|---|
| ClientInputMessage | 22 bytes | Player input + sequence# |
| ServerStateUpdateMessage | 6 + 38n bytes | Game state + ACKs |
| ProjectileSpawnMessage | 53 bytes | Trajectory parameters |
Client (30 Hz) ──[Input + Seq#]──> Server (20 Hz)
↓
Processes inputs
Updates physics
Detects collisions
↓
Client (60 FPS) <──[State + ACKs]─── Broadcasts
↓
Predicts local player
Interpolates remote players
Renders @ 60 FPS
- Lab 8 (Reliability):
InputHistoryBuffer.cs,ServerGameState.cs(ACK tracking) - Lab 9 (Latency):
SnapshotBuffer.cs,SimplePlayerController.cs(interpolation) - Debug Tools:
NetworkSimulator.cs(packet loss testing),ConnectionUI.cs
The game includes a built-in network simulator for testing:
- Enable Debug UI: Press Tab in-game
- Toggle Network Simulator: Check "Enable Network Simulation"
- Adjust Packet Loss: Use slider (0-50%)
- Observe: Retransmissions logged in console, gameplay stays smooth
Expected behavior at 30% packet loss:
- ~9 retransmissions per second
- 0% input loss (all inputs eventually delivered)
- Fully playable gameplay
| Deliverable | Status | Key Features |
|---|---|---|
| D3 (Labs 1-3) | ✅ Complete | UDP networking, binary serialization, threading |
| D4 (Lab 7) | ✅ Complete | Passive replication, full gameplay, client prediction |
| D5 (Labs 8-9) | ✅ Complete | ACK system, input redundancy, interpolation |
Total Development Time: ~40 hours across 6 sessions (Nov 2025 - Jan 2026)
- UDP socket programming with thread-safe architecture
- Binary protocol design and serialization
- Client-side prediction and server reconciliation
- Reliability over unreliable protocols (ACKs, retransmission)
- Interpolation and latency hiding techniques
- Thread.Sleep() freeze: Never block network threads
- Retransmission spam: Must track lastRetransmitTime to prevent loops
- Input queue buildup: Match client send rate to server capacity
"Retransmission is harder than it looks—you need careful timestamp management."
"Interpolation makes a huge difference—remote players at 60 FPS vs 20 Hz is night and day."
Educational project - MIT License