-
Notifications
You must be signed in to change notification settings - Fork 0
Networking Architecture
Multiplayer runs on Unity Netcode for GameObjects (NGO), transported over UnityTransport (raw UDP/IP, no relay or lobby service configured).
-
Host button: calls
NetworkManager.Singleton.StartHost(). The host is both the authoritative server and a client. It looks up and displays its own local IPv4 address so others know what to connect to. -
Client button: reveals an IP input (pre-filled with your own subnet, e.g.
192.168.1.) and a Connect button. -
Connect: sets the transport's connection data to the typed IP on port
7777, then callsStartClient().
Because this is a bare UnityTransport setup, all players must be reachable on the same LAN — there's no NAT traversal or relay yet. Adding Unity Relay would be the natural next step for internet play.
Movement/animation use custom ClientNetworkTransform / ClientNetworkAnimator (in Assets/Scripts/) instead of NGO's stock components — these make movement client-authoritative (the owning client's Transform/Animator drives the sync) rather than server-authoritative, which fits a fast local-play game better than it would a competitive/cheat-resistant one.
- Owning client presses
T→DartController(inPlayerShoot.cs) callsShootProjectileServerRpc(). -
Server instantiates the
Dart_V1prefab, gives it velocity, and spawns it as aNetworkObjectwith ownership assigned back to the throwing client (SpawnWithOwnership). - The dart replicates to all clients as a normal networked object.
-
Projectile.cs'sOnCollisionEnteronly runs its logic on the server (if (!IsServer) return). - If the dart hit an object tagged
"Player", the server callsThirdPersonController.TagPlayerServerRpc(true)on that player. - That RPC forwards to
TagPlayerClientRpc(true), setting_isTagged = trueon every client — this zeroes the tagged player's move speed inMove()(they can still look around, just not walk/run). - Separately,
ThirdPersonController.OnCollisionEnter(server-only) detects two players colliding and callsTagPlayerServerRpc(false)on the one that was hit — that's the "bump to unfreeze" mechanic. - The dart itself zeroes its velocity on impact and tells all clients to destroy it after a short delay (
DestroyProjectileClientRpc).
ColorController.cs gives each player a random color on spawn (NetworkVariable<Color>, server-authoritative value, broadcast to all clients), rerollable with C. This is currently the only per-player visual differentiator — there's no player name/tag UI yet.