Project

IDrive asymmetric multiplayer tank-crew prototype

System Design Document

IDrive System Design

A Unity 6 multiplayer tank-crew architecture where lightweight network player identities claim crew seats and drive one shared scene tank through synchronized movement, aiming, firing, AI destruction, and match-outcome systems.

The runtime model is server authoritative for movement, turret aim, weapon firing, reload state, enemy AI, and game outcome. Clients primarily provide seat-specific input and receive synchronized state through NetworkVariables, RPCs, NetworkObject spawning, and NetworkTransform replication.

Architecture Summary

Server-Authoritative Tank Crew Architecture

The system consists of one networked player tank placed in the scene, one lightweight networked player prefab for each connected user, a central role manager, a local camera manager, networked projectile and enemy actors, and a networked outcome manager.

Network Session Actor NetworkManager owns transport configuration, host or client startup, player prefab assignment, prefab lists, general network timing, and a tick rate of 30.
Crew Player Actor NetworkTankCrewPlayer represents a connected human participant, not a physical tank body.
Shared Tank Actor PlayersTank contains NetworkObject, NetworkTransform, NetworkTankController, NetworkTurretController, and NetworkTankWeapon.
Enemy Actor TankEnemy is a moving networked AI target that patrols, explodes, and despawns for all clients.

Runtime Object Model

NetworkManager
Transport + Tick 30
Crew Player
Identity + Input
Role Manager
Seat Registry
PlayersTank
Shared Vehicle
Projectile
Network Spawn
TankEnemy
Patrol + Despawn

The player vehicle is scene-resident, while connected users spawn as lightweight crew identities.

Scene Topology

  • NetworkManager with Unity Transport, NetworkConnectionAndRoleUI, player prefab assignment, prefab lists, and general network timing.
  • Tank Crew Role Manager with NetworkObject, TankCrewRoleManager, and NetworkGameOutcomeManager.
  • Local Role Camera Manager referencing Commander Camera, Driver Camera, Spotter Camera, and Fire Control Camera.
  • PlayersTank as the main crew-operated vehicle.
  • Thirteen enemy tank instances based on the TankEnemy prefab.
  • Role canvases including CommanderCanvas, DriverCanvas, SpotterCanvas, FireControlCanvas, and NormalCanvas.
  • Support UI such as ReloadProgress and outcome text objects.

Why The Unity Baseline Matters

The project depends on modern Unity APIs and package behavior, including FindFirstObjectByType, FindObjectsByType, Netcode NetworkVariables and RPCs, NavMeshAgent patrol behavior, and UGUI image fill for reload feedback.

Spawn Model

The scene does not dynamically spawn the player vehicle. The shared tank is a scene authority object, while connected users spawn as lightweight network player identities that request control seats within that tank.

Authority And Flow

Who Owns What

Authority is intentionally centralized. Clients send role-specific intent upward; the server owns simulation, seat state, enemy behavior, projectiles, reload state, and outcomes.

Network Authority

  • Server-owned: driver movement state inside NetworkTankController.
  • Server-owned: turret yaw and pitch state inside NetworkTurretController.
  • Server-owned: weapon fire permission, projectile spawning, and reload progress inside NetworkTankWeapon.
  • Server-owned: enemy patrol and collision-driven destruction.
  • Server-owned: outcome resolution in NetworkGameOutcomeManager.
  • Server-owned: role-seat ownership in TankCrewRoleManager.
  • Client-owned: connection initiation, local seat requests, local keyboard polling through TankCrewInputClient, and local camera presentation through LocalRoleCameraManager.

Synchronization Methods

  • ServerRpc calls carry player intent upward from client to server.
  • NetworkVariables publish seat assignments, turret angles, shell loaded state, reload progress, and outcome state.
  • ClientRpc is used for muzzle-flash playback at shot time.
  • NetworkObject spawning replicates projectiles and supports despawn of projectile and enemy objects.
  • NetworkTransform handles position and rotation replication for projectiles and networked tanks.

Session And Role Flow

NetworkConnectionAndRoleUI exposes IP and port fields plus Client, Host, and Server startup buttons. It also supports a command-line server argument so a process can auto-start as a server on launch.

After a client connects, the local player prefab spawns. TankCrewPlayer sets a static Local reference for the owning client and listens for AssignedRoleValue changes. If the player has no role, the role UI renders available seats from TankCrewRoleManager.

Seat Registry

TankCrewRoleManager stores one NetworkVariable seat owner ID for each role: Commander, Driver, Spotter, and FireControl. On request, the server validates that the seat is free, releases any previous seat held by that client, assigns the requested seat, and updates the player actor's AssignedRoleValue.

On disconnect, TankCrewRoleManager clears the departing client from its occupied seat and resets the role on the related player object if still present.

Subsystem Breakdown

How The Multiplayer Prototype Holds Together

Each subsystem is narrow: local presentation switches cameras, client input sends intent, the vehicle simulates on the server, and combat resolves through networked projectiles and enemy destruction.

Local Presentation

LocalRoleCameraManager converts the abstract role assignment into a player-visible presentation state. It owns references to four role cameras and optional role-specific behaviours and objects. When ApplyRole is called, it enables the correct camera, toggles that camera's AudioListener, and activates the role-linked behaviour or object arrays.

The current scene wiring indicates role canvases and role cameras are pre-placed and switched locally rather than built dynamically. The driver camera doubles as the lobby or no-role fallback.

Input Pipeline

  • TankCrewInputClient is enabled only on the owning player object.
  • Each frame it checks the assigned role and routes input to the matching subsystem.
  • Driver path: throttle, steering, and brake are sent every inputSendInterval to NetworkTankController.SubmitDriverInputServerRpc.
  • Spotter path: yaw and pitch are sampled as a Vector2 and sent to NetworkTurretController.SubmitAimInputServerRpc.
  • Fire-control path: fire presses call RequestFireServerRpc; reload held state is sent through SetReloadHeldServerRpc when it changes or when the periodic send window opens.
  • This keeps client logic thin and avoids duplicating movement or combat simulation on the client.

Vehicle Motion

  • NetworkTankController is responsible for hull motion and runs only on the server in FixedUpdate.
  • Submitted inputs are clamped and converted into smoothed movement velocity and turn velocity.
  • If a non-kinematic Rigidbody is present, the controller uses MovePosition and MoveRotation; otherwise it falls back to direct transform updates.
  • The script disables NavMeshAgent in Awake if one exists on the tank so AI navigation cannot compete with player-controlled network movement.
  • Scene movement tunables are forward speed 7, reverse speed 4, turn speed 80, acceleration 18, and turn acceleration 180.

Turret And Weapon

  • NetworkTurretController owns two server-written NetworkVariables: Yaw and Pitch.
  • Clients submit aim direction as normalized intent only.
  • The server integrates that intent over time, clamps the angles, and every instance applies the resulting local rotations to the configured yaw and pitch pivots.
  • NetworkTankWeapon owns ShellLoaded and ReloadProgress.
  • Only authorized fire-control clients can request fire or hold reload.
  • On fire, the server validates loaded state, spawns a projectile from the barrel fire point, optionally spawns its NetworkObject, schedules lifetime cleanup, plays muzzle flash on all clients, and resets reload state.
  • Reload is hold-to-complete; the active scene uses a three-second reload, starts loaded, and does not reset progress on release.

Projectile And Damage

  • Projectile actors are based on NetworkRpgProjectile.
  • RPGRounds ensures impact resolution runs on the server when the projectile is network-spawned.
  • On collision, RPGRounds determines a contact point, spawns a collision effect locally or through ClientRpc, and then despawns or destroys itself after a short delay.
  • TankExplode accepts collisions from objects tagged Projectiles or from objects carrying RPGRounds.
  • On the authoritative side, TankExplode stops navigation, disables EnemyPatrol, activates explosion effects, plays audio, applies force to child rigidbodies, ejects the tank head upward if configured, and despawns the NetworkObject after three seconds.
  • The damage logic is intentionally coarse: one effective hit equals one destroyed enemy tank.

Enemy AI And Outcome

  • EnemyPatrol is simple roaming AI built around NavMeshAgent.
  • On the authoritative side, the agent ensures it is on a valid NavMesh, can set the attached Rigidbody kinematic, then repeatedly chooses a random point within patrolRange, waits at arrival, and picks a new point.
  • On non-authoritative instances, EnemyPatrol disables local agent simulation and exits.
  • The current TankEnemy prefab uses patrolRange 30 and waitTime 2.
  • NetworkReloadProgressUI binds NetworkTankWeapon.ReloadProgress to a UGUI Image fill amount and looks up the weapon if it has not been assigned directly.
  • NetworkGameOutcomeManager owns OutcomeState with None, Win, and Lose values. On the server, it periodically counts remaining non-exploded enemy tanks carrying the Enemy tag. After enemies have existed and the count reaches zero, it sets the shared outcome to Win.

Prefab And Legacy Inventory

Runtime Assets And Non-Core Content

NetworkTankCrewPlayer.prefab

Represents a connected user. Components are intentionally minimal: NetworkObject, TankCrewPlayer, and TankCrewInputClient. This keeps seat ownership and input decoupled from the shared tank object.

NetworkRpgProjectile.prefab

A networked shell actor containing NetworkObject, NetworkTransform, Rigidbody, SphereCollider, and RPGRounds. It is spawned on the server by NetworkTankWeapon and replicated to clients.

TankEnemy.prefab

A hostile patrol target with NavMeshAgent patrol logic, explosion behavior, audio, colliders, network replication, and child mesh or marker content. Its design is AI-light and reaction-heavy: move until hit, then explode and despawn.

Explosion.prefab

Shared visual effect referenced by projectile collision and enemy destruction setup.

Legacy Elements

  • Single-player prototype scripts such as DriverTankController, FireControlWeapon, and SpotterTurretAim are present in Assets but were not referenced by current main scene search results.
  • Client-Server-Sample-main exists at repository root as reference material and is separate from the actual IDrive runtime content under the active Unity project.
  • Third-party environment, decal, and explosion packages provide visual support but are not IDrive-specific logic systems.

Architectural One-Liner

IDrive is a server-authoritative multiplayer tank-crew architecture where lightweight network player identities claim crew seats and drive one shared scene tank through synchronized movement, aiming, firing, AI destruction, and match-outcome systems.