MULTIPLAYER LOCAL TIC TAC TOE GAME
"LET'S MULTIPLAYER SOMETHING"
"LET'S MULTIPLAYER SOMETHING"
A multiplayer Tic-Tac-Toe game developed in Unity, designed to showcase server-authoritative networking, lobby-to-match flow, and clean separation between network session management, gameplay logic, and UI.
Team size: Solo Developer
Role: Gameplay Programmer, Network Architecture, Systems Design and UI & Game Flow
Stack: Unity, C#, Unity Netcode for GameObjects (NGO), Unity Transport (UDP)
Art & Design: Unity 2D (URP), TextMeshPro
Host / Join multiplayer lobby over local network (UDP)
Server-authoritative 3x3 tic-tac-toe with turn validation
Synchronized game state using NetworkVariables
Lobby → Match → Lobby scene flow with networked scene loading
Restart and disconnect-to-lobby from inside the match
Decoupled lobby UI with RPC-based warning messages
Local arena UI driven by gameplay state events
Implemented a two-scene multiplayer flow:
Lobby → Game Scene → Lobby
Built NetworkSessionBootstrap as the lobby entry point for Host, Join, Disconnect, and Start Match
Uses NGO Scene Management to load the game scene for all connected clients
NetworkSessionBridge persists on the NetworkManager via DontDestroyOnLoad to handle returns across scenes
Designed a layered networking setup with clear responsibilities:
NetworkSessionBootstrap — connection lifecycle and lobby actions
NetworkSessionBridge — cross-scene session coordination and safe shutdown
MenuNotifier — networked UI warnings through RPCs
TagNetworkPlayer — minimal player prefab to satisfy NGO spawn requirements
Separated lobby presentation (MainMenuNetworkUI) from networking logic
Built TicTacToeGame as the authoritative match controller on the server:
Clients request moves through ServerRpc
Server validates turn order, cell availability, and match status
Updated state is synced to all clients via NetworkVariable<TicTacToeState>
Match lifecycle includes playing, win/draw detection, restart, and return to lobby
Created a compact networked state model:
TicTacToeState holds board, current turn, match status, and next-match starter
BoardEncoding packs all 9 cells into a single integer using base-3 encoding
Implements INetworkSerializable for efficient NGO synchronization
Winner detection runs on the server after every valid move
Implemented GameManager to track session-level player mapping:
Host registered as Player 1 (X)
Guest registered as Player 2 (O)
Resolves local player identity for UI and turn feedback
Clears session data when returning to lobby
Built MainMenuNetworkUI as a pure visual controller:
Host-only, both players, and disconnected states
Local cursor visibility per client
Temporary warning messages with timed display
Network layer pushes UI updates without embedding presentation logic inside connection code
Created TicTacToeUI as the local match interface:
3x3 grid interaction, status text, restart, and disconnect
Subscribes to TicTacToeGame.StateChanged for reactive updates
Disables invalid interactions locally while server remains the source of truth
Supports auto-detection of grid buttons named Button 0 through Button 8
Implemented robust return-to-lobby behavior:
Host-initiated disconnect returns all players to lobby and shuts down the session
Client-side fallback loading when connection is lost mid-match
Duplicate NetworkManager cleanup when reloading the lobby scene
Timed coroutine ensures clients are not cut off before scene transition completes
Challenge: Preventing invalid moves and turn cheating in a client-server setup
Solution: Moved all move validation and win/draw resolution to the server, exposing only request methods to clients and syncing results through a single NetworkVariable
Challenge: Returning from the game scene to lobby without breaking NGO references or leaving duplicate managers
Solution: Created NetworkSessionBridge on a persistent NetworkManager object and coordinated shutdown, scene load, and lobby reset through a dedicated return routine
Challenge: Updating warnings and lobby visuals across host and clients without tightly coupling UI to connection handlers
Solution: Introduced MenuNotifier with targeted ClientRpc/ServerRpc calls and kept MainMenuNetworkUI as a presentation-only layer
Challenge: Avoiding duplicate UI resets and false warnings when the host manually shuts down the lobby
Solution: Added shutdown flags and differentiated manual disconnect flow from transport failure and remote client drop events
Add relay / NAT traversal support for easier online play outside LAN
Introduce matchmaking or room codes instead of manual IP connection
Extract player identity resolution into a dedicated network service
Add reconnection handling for dropped clients mid-match
Expand UI feedback with animations, sound, and clearer turn indicators
Designed a modular multiplayer architecture with clear separation between session, gameplay, and UI
Implemented server-authoritative tic-tac-toe using NGO RPCs and NetworkVariables
Built a reliable lobby-to-match-to-lobby flow with persistent network session handling
Focused on practical multiplayer patterns: validation on server, presentation on client, and safe session teardown