Tower Crushers

Unity, C#, UNet

Tower Crushers is a 1-on-1 multiplayer Unity 3D Physics game, where each player constructs a unique base with limited points and fights to see who can first destroy all opponent structures.

Made in Unity3D using C# and UNet (Unity Multiplayer Services)

This was a university team project (4 people) spanning 2 months, back in 2019. Programming abilities used include:

  • UNet Networking: The main focus of the project. UNet RPC calls (Client & Server RPC communication) was utilised to mediate gameplay between two players over Unity Multiplayer Services hosting.

    • Assigned server or client authority to specific functions and objects, which on call will traverse the network and ‘invoke’ on the corresponding authority. Opponent connects to host’s room via Unity Services, and exchanges RPC command calls that way.

      • Methods such as spawn local objects and update local states (catapult, tower) were set as client calls, whereas methods such as onhit / destroy (destructibles), fireball, invincibility and update Game Flow (Build Over, Game Over) states were set as server calls.

    • Care was taken to ensure correct calls were made at correct times, NetworkIdentities were instantiated and destroyed as needed, and NetworkManagers were set up appropriately & transferring data over KCP Transport as required.

    • Connection was achieved using a simple [Host Game] and [Join Game: IP Address] system. This implementation was used to mimic a P2P connection, even though the opponent’s side had a bit of latency due to the nature of Unity Multiplayer Services communication.

  • 3D Physics: Projectile physics and Catapult launch were calculated using physics forces and AddVector & AddAngularVelocity. Collision physics with Rigidbody were also used for hit detection to structures.

  • Base Building: Simple camera change and object spawn (with cost per building) was used for the base building module. Each base is a NetworkIdentity that interacts with projectiles and updates its state periodically on both players’ machines.

  • ParticleFX - Used for fireball special power.

Credits:

Game music loop #13 - BloodPixelHero

Code Here: