API Multiplayer Chatroom • University Project — Programming APIs
Engine: Unity 2022 LTS • Framework: Netcode for GameObjects (MLAPI) • Language: C# • Team: 3 Programmers (my focus – Chat UI & Team Systems)
Overview
For my Programming APIs university module, our team of three created a small multiplayer chatroom using Unity’s Netcode for GameObjects. I implemented the entire player-to-player communication system, from the text chat box and input handling to team-based visibility and player identification.
Footage
Image Gallery
My contributions
- Implemented team-restricted chat using
ServerRpcandClientRpcmessaging inTeamChat. - Created the singleton
ChatUIManagerthat manages input fields and dynamically shows the correct team chat window. - Built name-entry and team assignment systems (
NameTag,PlayerID) withNetworkVariable<FixedString32Bytes>for synced data. - Maintained the player list UI (
PlayerListText) to reflect join/leave events across clients. - Added
FaceCamerautility to keep nameplates oriented to the active camera.
Representative code
// TeamChat.cs — send chat messages only to players on the same team
[ServerRpc(RequireOwnership = false)]
private void SendMessageServerRpc(string message, string team, ServerRpcParams rpcParams = default)
{
BroadcastMessageToTeamClientRpc($"{playerID.PlayerName}: {message}", team);
}
[ClientRpc]
private void BroadcastMessageToTeamClientRpc(string message, string team)
{
if (playerID.PlayerTeam.ToString() == team)
{
if (team == "Red")
ChatUIManager.Instance.teamAChatDisplay.text += message + "\n";
else if (team == "Blue")
ChatUIManager.Instance.teamBChatDisplay.text += message + "\n";
}
} // PlayerID.cs — assign random team and propagate player name to all clients
private void AssignRandomTeam()
{
string team = Random.Range(0, 2) == 0 ? "Red" : "Blue";
playerTeam.Value = new FixedString32Bytes(team);
}
[ServerRpc]
private void AssignRandomTeamServerRpc()
{
AssignRandomTeam();
} Reflection
This project solidified my understanding of RPC flow, client-server authority, and NetworkVariable data replication within Unity. I also learned the importance of decoupling UI logic from networking so multiple clients can see consistent state updates.
Note: Built for my Programming APIs module to demonstrate teamwork, Netcode integration, and networked UI systems.