Programming

> Zayar Aung

# Overview

This game was developed using Unity 2022.3.56. In the early stages of development—before server implementation—the game was first designed as a split-screen local multiplayer. However, since the final product is an online multiplayer game, the programming architecture consists of two sides:

  • Client Side – the base game system and local player logic
  • Server Side – handles data communication between the two players

# CLIENT SIDE

The client side handles the core gameplay systems. This includes the implementation of fundamental mechanics like player control and item interaction. Two major components are:

  • The Player (the controllable character)
  • The Throwable Items (interactable weapons)

# PLAYER

This is the character controlled by the local (client-side) player. The Player GameObject consists of multiple scripts that work together. The Camera, although separate from the Player object, follows it and has its own logic.

Player Object
  • Player.cs
    Manages basic information (e.g., HP, Player Number) and handles object detection, grabbing, and throwing.
  • PlayerMovement.cs
    Controls player movement (walking, sprinting, jumping, dashing) and performs collision checks.
  • ObjHolder.cs
    Updates the position of held items and adjusts holding positions when necessary.
  • PlayerSFXPlayer.cs
    Plays sound effects related to the player.
  • ControlManager.cs
    Determines the player's control scheme (e.g., Xbox or PlayStation).
Camera Object
  • CameraController.cs
    A robust third-person camera system that smoothly follows the player.

🛠 Technical Highlights

Dashing Mechanic (PlayerMovement.cs)
The dash coroutine moves the player rapidly while performing raycast checks to prevent clipping through walls or terrain. If an obstacle is detected, the player will only dash up to the point of collision. During the dash, the player's hurtbox is disabled to prevent damage.

Custom Camera Controller (CameraController.cs)
Instead of using Unity's Cinemachine, this camera system is built from scratch. It provides a modern third-person shooter feel, with adjustable settings (distance, offset, rotation limits, inversion, shoulder swap, etc.) all tweakable via the Unity Inspector.


# NET PLAYER

This is the character controlled by the opponent through the server. Unlike the client-side Player, the Net Player is essentially a "puppet" that acts based on server commands. It is not a separate object but is converted from a regular Player object by the NetController.

Net Player Scripts
  • NETPlayer.cs
    Receives opponent data from the NetController and performs corresponding actions like movement, grabbing, and throwing.
  • ObjHolder.cs
    Same function as on the client side – manages held object positions.
  • PlayerSFXPlayer.cs
    Plays sound effects for the Net Player.
NetController Object
  • NetController.cs
    Handles all data exchange between clients. Based on the player's ID (Player 1 or 2), it turns the opposing Player object into a Net Player, removing unnecessary scripts/components.

🛠 Technical Highlights

Net Player Movement (NETPlayer.cs)
The UpdatePosition() method moves the Net Player to the location received from the server and updates its facing direction. It also calculates movement direction based on position deltas and updates the appropriate animation state.


# THROWABLE ITEMS

These are objects players throw at each other. They are divided into three classes: small, medium, and large, each differing in size, damage, and speed. Some items are variants with special effects.

Base Throwable Object
  • ThrowableObject.cs
    Core script managing the grabbing and throwing mechanics. Attributes like damage, throw speed, held position/rotation can be adjusted in the Inspector.
  • ObjHitbox.cs
    Handles collision and damage to opponents.
  • ObjSFXPlayer.cs
    Manages sound effects for items.
Variant Objects (inherit from ThrowableObject.cs)
  • ThrowableGrenade.cs
    Explodes after being thrown and deals area damage.
  • ThrowableSpear.cs
    Splits into multiple copies after being thrown.
  • ThrowableSkull.cs
    Homes in on the opponent after being thrown.
  • ThrowableMeteor.cs
    Summons a giant meteor that crashes at the impact location.
  • ThrowableFlan.cs
    Launches players high into the air when jumped on.

> Francesco Paolo Mariani

# SERVER SIDE

The physical setup follows a client-server model, with one server and two clients connected via Ethernet cables through a switch hub.

We developed a basic UDP client-server application in C#, where the server acts as a bridge between the clients by receiving an array of bytes from Client A and forwarding it to Client B, and vice versa. The server performs very minimal data processing.
The reason for the limited processing is that the server was designed primarily for a LAN-based setup, so we decided to keep the implementation simple.


# CLIENT THREADING

On the client side, we implemented data sending and receiving using a separate thread that leverages basic UDP data exchange functionality from C# System.Net library.
We also added a stopwatch to measure the transmission time and make the thread wait accordingly, which helps avoid unnecessary processing and reduces memory usage on the client's machine.


# PROCEDURAL TERRAIN

To make each game session feel unique, we used Perlin noise and a simple heightmap mesh generation algorithm to create procedural terrain based on a randomly generated seed.
Initially, we considered using the Marching Cubes algorithm for more advanced terrain destructibility, but we discarded this idea when we switched to an online multiplayer setup due to time constraints.



> Chen Yu Ren

# UI Features Implemented

  • Title screen navigable with controllers (Xbox/PlayStation) and mouse/keyboard, with background music and sound effects.
    • TitleScreen.cs
    • HoverOnlyButton.cs

  • Settings screen for adjusting background music volume, controller type, and sensitivity.
    • GameSettings.cs
    • ControllerColumn.cs
    • SliderColumn.cs

  • Tutorial screen introducing controls, with reactive controller icons that highlight the selected control type and a language toggle (English/Japanese).
    • Tutorial.cs
    • ControllerIcon.cs
    • TutorialText.cs

  • Countdown animation at the start of each game.
    • Countdown.cs
    • CountdownEffect.cs

  • HUD displaying jump/dash charges and a cell-based health bar that shakes and flashes red on damage.
    • CellHPBar.cs
    • DashDotsUI.cs
    • JumpDotsUI.cs
    • Triangle.cs

  • Pause menu allowing players to quit, disabling movement inputs while preserving online sync.
    • InGameMenu.cs
      (with parts in Player.cs, PlayerMovement.cs, CameraControl.cs)

  • End screen showing winner/loser and returning to the title screen with settings preserved.
    • WinnerDisplay.cs