Netcode Bootstrap
This commit is contained in:
@@ -2,20 +2,22 @@
|
||||
|
||||
Multiplayer game on **Unity DOTS (Entities) + Netcode for Entities** — server-authoritative, input-only clients, client prediction. This file is committed and is the authoritative, cross-machine source of conventions. The `/dots-dev` skill drives feature work; the one-time stack setup lives in `Docs/dots-setup-task.md`.
|
||||
|
||||
## Stack (installed versions — Unity 6.4.7 / `6000.4.7f1`)
|
||||
## Stack — reverting to Unity 6.4.7 (stable) as of 2026-05-30
|
||||
|
||||
| Package | Version | Notes |
|
||||
|---|---|---|
|
||||
| `com.unity.entities` | **6.4.0** | Entities/Collections/Graphics now track the **Editor** version (6.x), not the old 1.x line. |
|
||||
| `com.unity.entities` | **6.4.0** | Entities/Collections/Graphics track the **Editor** version (6.x). |
|
||||
| `com.unity.entities.graphics` | **6.4.0** | Renders entities under URP 17.4. |
|
||||
| `com.unity.collections` | 6.4.0 | (transitive) |
|
||||
| `com.unity.netcode` | **1.13.2** | Netcode **for Entities** (ECS). NOT `com.unity.netcode.gameobjects`. Independent 1.x versioning. |
|
||||
| `com.unity.physics` | **1.4.6** | Unity Physics (DOTS). Independent 1.x. |
|
||||
| `com.unity.netcode` | **1.13.2** | Netcode **for Entities** (ECS). NOT `com.unity.netcode.gameobjects`. Independent 1.x line on Unity 6.4. |
|
||||
| `com.unity.physics` | **1.4.6** | Unity Physics (DOTS). Independent 1.x line on Unity 6.4. |
|
||||
| `com.unity.transport` | 2.7.2 | (transitive) |
|
||||
| `com.unity.burst` | 1.8.29 | (transitive) |
|
||||
| `com.unity.mathematics` | 1.3.3 | (transitive) |
|
||||
|
||||
> **Upgrading Unity 6.4 → 6.6:** Entities/Collections/Graphics would renumber to 6.6.x; Netcode/Physics stay independent 1.x (slated to become Core packages later in 2026). The setup here (asmdefs, bootstrap, subscene, smoke test) is forward-compatible — just let packages re-resolve. The `NetCodeTestWorld` access constraint below is **unchanged** by the upgrade.
|
||||
> ⚠️ The values above are the **Unity 6.4.7** set being reverted to — **verify against `packages-lock.json` after the editor downgrade re-resolves**, and reconcile `manifest.json` if the brief 6.6 upgrade left explicit version pins.
|
||||
|
||||
> **Version history & status (2026-05-30):** built on **6.4.7** (`6000.4.7f1`; Netcode 1.13.2 / Physics 1.4.6 / Entities 6.4.0). Briefly upgraded to **6.6.0a6**, where Netcode→6.6.0, Physics→6.5.0, Entities→6.5.0 all **renumbered** into the editor line — BUT the alpha's **Netcode/Transport runtime is broken** (all in-editor connections fail with "invalid wrapped network interface"; **confirmed engine bug** via a zero-gameplay repro — see `Docs/Vault` DR-002 and `Docs/UnityBugReport-Netcode-Transport-6.6.0a6.md`). **→ Reverting to Unity 6.4.7 for stable netcode runtime.** If returning to 6.6 later, expect the renumber and re-test the runtime. The M1 player slice should port to 6.4 / Netcode 1.13.2 with no or minimal changes — recompile and `read_console` after the downgrade.
|
||||
|
||||
## Namespaces & assembly split
|
||||
|
||||
@@ -23,17 +25,25 @@ Root namespace: **`ProjectM`**. Code lives under `Assets/_Project/Scripts/` in f
|
||||
|
||||
| Assembly | Namespace | Runs in | References |
|
||||
|---|---|---|---|
|
||||
| `ProjectM.Simulation` | `ProjectM.Simulation` | **client + server** worlds | Entities, Collections, Mathematics, Burst, Unity.Physics, Unity.NetCode |
|
||||
| `ProjectM.Client` | `ProjectM.Client` | client world only | + Simulation, Unity.Entities.Graphics |
|
||||
| `ProjectM.Server` | `ProjectM.Server` | server world only | + Simulation, Unity.NetCode |
|
||||
| `ProjectM.Authoring` | `ProjectM.Authoring` | bake time (+ scene runtime) | Simulation, Entities, Mathematics, Unity.NetCode |
|
||||
| `ProjectM.Simulation` | `ProjectM.Simulation` | **client + server** worlds | Entities, **Unity.Transforms**, Collections, Mathematics, Burst, Unity.Physics, Unity.NetCode |
|
||||
| `ProjectM.Client` | `ProjectM.Client` | client world only | + Simulation, Unity.Entities.Graphics, **Unity.InputSystem** |
|
||||
| `ProjectM.Server` | `ProjectM.Server` | server world only | + Simulation, **Unity.Transforms**, Unity.NetCode |
|
||||
| `ProjectM.Authoring` | `ProjectM.Authoring` | bake time (+ scene runtime) | Simulation, Entities, **Unity.Entities.Hybrid**, Collections, Mathematics, Unity.NetCode |
|
||||
|
||||
- **Simulation** = components + systems shared by both worlds (most gameplay). **Client/Server** = world-specific. **Authoring** = `…Authoring` MonoBehaviours + `Baker<T>`.
|
||||
- Other folders: `Assets/_Project/Subscenes/` (baked entity subscenes), `Assets/_Project/Prefabs/`, `Assets/_Project/Tests/EditMode/`.
|
||||
|
||||
### Build gotchas (learned — M1, 2026-05-30)
|
||||
|
||||
- **`Unity.Transforms` must be a DIRECT asmdef reference** for any assembly whose source-gen'd systems use `LocalTransform`/`LocalToWorld`. It is its own assembly; transitive visibility compiles your hand-written code but the Entities generator emits **CS0246** inside the `*.g.cs`.
|
||||
- **Authoring asmdefs need `Unity.Entities.Hybrid`** (defines `Baker<T>`) **and `Unity.Collections`** (baking source-gen). A nested baker class must **not** be named `Baker` (it shadows `Baker<T>` → CS0308/CS0246) — name it `FooBaker`.
|
||||
- **Never name an `IComponentData` `PlayerInput`**, and don't `using UnityEngine.InputSystem;` in a file that references such a component: it collides with `UnityEngine.InputSystem.PlayerInput`, and the Entities generator binds `RefRW<…>` to the *managed* class → a misleading **CS8377 "must be a non-nullable value type"**. Fully-qualify Input System types (`UnityEngine.InputSystem.Keyboard.current`) instead.
|
||||
- `IInputComponentData` requires implementing **`FixedString512Bytes ToFixedString()`**.
|
||||
- An input-gather system that reads the managed Input System belongs in `GhostInputSystemGroup` as a **non-Burst `ISystem`** (or `SystemBase`), never inside the prediction loop.
|
||||
|
||||
## Bootstrap & worlds
|
||||
|
||||
- `ProjectM.Simulation.GameBootstrap : ClientServerBootstrap` → overrides `Initialize`, sets `AutoConnectPort = 0` (no auto-connect), calls `CreateDefaultClientServerWorlds()`. Entering Play Mode creates separate `ServerWorld` (`WorldFlags.GameServer`) and `ClientWorld` (`WorldFlags.GameClient`) — verified.
|
||||
- `ProjectM.Simulation.GameBootstrap : ClientServerBootstrap` → overrides `Initialize`, sets `AutoConnectPort = 7979` (in-editor auto-connect over IPC; set in M1 — was 0), calls `CreateDefaultClientServerWorlds()`. Entering Play Mode creates separate `ServerWorld` (`WorldFlags.GameServer`) and `ClientWorld` (`WorldFlags.GameClient`) — verified.
|
||||
- `Assets/_Project/Subscenes/Gameplay.unity` is wired into `SampleScene` (GameObject `GameplaySubScene`) as a baking target. Replace `SampleScene` with a dedicated bootstrap scene when building for real.
|
||||
|
||||
## DOTS / ECS conventions (authoritative summary)
|
||||
|
||||
Reference in New Issue
Block a user