A real-time, 1v1 multiplayer chess game built with Unity and Photon PUN 2, featuring room-based matchmaking, full chess rule logic (including en-passant and pawn promotion), synced camera/turn ownership, and a simple XP/rewards loop.
⚠️ Archive / Portfolio Notice This is an older personal project that has been pulled out of storage, cleaned up, commented, and reorganized to be published here as a code sample / portfolio piece. It is not actively maintained and isn't meant to be a production-ready game — it's shared to demonstrate multiplayer architecture, gameplay-system design, and general C# code quality. Expect some legacy quirks and a few TODOs along the way.
- Two players connect through Photon, get matched into a room, and play a full game of chess in real time.
- All board logic (legal moves, captures, en-passant, pawn promotion, check-for-king-capture end state) runs synchronized across both clients via Photon RPCs.
- Each player only controls their own camera/view; turn ownership is transferred between players as the game progresses.
- A lightweight menu flow handles connecting to Photon, setting a nickname, quick-matchmaking or joining a friend's room by ID.
- A basic XP counter and rewarded/interstitial ad hooks are included as a stand-in for a simple progression/monetization loop.
| Script | Responsibility |
|---|---|
MenuManager |
Connects to Photon, handles nickname/XP setup, matchmaking (random or friend room ID) |
GameManager |
Room lifecycle (join/leave), player spawning, camera setup, game start/finish state |
BoardManager |
Chess rules: selection, movement, captures, en-passant, promotion, turn switching, end-game detection |
BoardHighlights |
Pooled highlight tiles for showing legal moves on the board |
Chessman (+ piece subclasses) |
Per-piece move generation logic |
AdManager |
Banner / interstitial / rewarded ad hooks |
- Engine: Unity
- Networking: Photon PUN 2 (rooms, RPCs, ownership transfer)
- UI: TextMeshPro
- Persistence:
PlayerPrefsfor nickname/XP (simple local storage, no backend)
Assets/
├─ Scripts/
│ ├─ MenuManager.cs
│ ├─ GameManager.cs
│ ├─ BoardManager.cs
│ ├─ BoardHighlights.cs
│ ├─ Chessman.cs (+ King, Queen, Rook, Bishop, Knight, Pawn)
│ └─ AdManager.cs
├─ Prefabs/
├─ Scenes/
└─ ...
- Clone the repo.
- Open the project in Unity (see
ProjectSettingsfor the exact version used). - Import/configure Photon PUN 2 with your own
PhotonServerSettingsApp ID. - Open the Menu scene and press Play — two instances (or two builds) are needed to test a full match.
As part of preparing this repo for publishing, the scripts have been:
- Reorganized into clearly labeled
#regionblocks (fields, lifecycle, RPCs, gameplay, utility, etc.) - Documented with XML/inline comments explaining intent, especially around Photon RPC flow and chess-rule edge cases (en-passant, promotion, turn ownership transfer)
- Lightly refactored for readability (extracted small helper methods, clearer local variable names)
Public/serialized fields, RPC method names, and Inspector-facing method signatures were deliberately left unchanged to avoid breaking existing scene/prefab references — so a few original naming quirks (and at least one known typo in a cross-script method call) are intentionally still present rather than silently "fixed."
- No check/checkmate detection — the game currently ends only on a king capture.
- No reconnection/resume handling if a player disconnects mid-match.
- No backend/leaderboard — XP is stored locally per device.
- Minimal input validation and error handling around Photon connection failures.
This project is shared for educational and portfolio purposes. Feel free to read through the code and borrow ideas — see the repository's license file (or open an issue) for reuse terms.