feat(Car): wire NWH Vehicle Physics 2 — scripts only, scene/prefabs still TODO

Code-only first pass. The local Player.prefab (ball) is still in the scene
until the user creates the PlayerCar / RemoteCar prefab variants in the Editor.

New scripts:
- VehicleLocalSetup: attaches name label + colored capsule marker to the local
  vehicle, registers its Rigidbody with NetworkManager for broadcast.
- RemoteVehicleSync: snapshot interpolation for remote vehicles. Disables the
  NWH VehicleController + every WheelController + every AudioSource on init.
  Makes the rigidbody kinematic, MovePosition-driven from network. Disables all
  non-trigger colliders during the 1.5s spawn grace window to avoid ejecting
  overlapping locals at connect.

Adapted scripts:
- NetworkManager: RegisterLocalVehicle(Transform, Rigidbody) replaces the
  FindFirstObjectByType<PlayerController>() lookup. Remote spawn now wires
  RemoteVehicleSync instead of RemotePlayerController.
- LobbyUI: OnConnected drives VehicleLocalSetup.SetupLocal; OnDisconnected
  toggles NWH.VehicleController instead of PlayerController.
- GameManager.SetPlayerActive: toggles VehicleController, not PlayerController.
- DebugNetworkUI: live position read from VehicleController.vehicleRigidbody.
- ChatUI: drops PlayerController.ResetInputs() (NWH polls Input System each
  frame; no manual reset needed when chat opens).
- StatsTracker: drops dead _pc field; Rigidbody still gets resolved via
  GetComponent on the host GameObject (will be the vehicle on Car).

Frontend (deployed earlier on master): build_ball replaces pretty_build assets.
This commit is contained in:
2026-05-20 18:34:40 +02:00
parent 32becc12f9
commit 103f8859d4
14 changed files with 444 additions and 53 deletions

View File

@@ -52,12 +52,12 @@
}
var buildUrl = "Build";
var loaderUrl = buildUrl + "/pretty_build.loader.js";
var loaderUrl = buildUrl + "/build_ball.loader.js";
var config = {
arguments: [],
dataUrl: buildUrl + "/pretty_build.data",
frameworkUrl: buildUrl + "/pretty_build.framework.js",
codeUrl: buildUrl + "/pretty_build.wasm",
dataUrl: buildUrl + "/build_ball.data",
frameworkUrl: buildUrl + "/build_ball.framework.js",
codeUrl: buildUrl + "/build_ball.wasm",
streamingAssetsUrl: "StreamingAssets",
companyName: "DefaultCompany",
productName: "BallProject",

View File

@@ -3,8 +3,8 @@ import { useState, useEffect, useCallback } from 'react'
// Check if Unity build files exist
const UNITY_BUILD_PATH = '/unity-build/Build'
// Cache-busting version — update this after each Unity build
const UNITY_BUILD_VERSION = '20260520c'
const BUILD_PREFIX = 'pretty_build'
const UNITY_BUILD_VERSION = '20260520d'
const BUILD_PREFIX = 'build_ball'
const LOADER_URL = `${UNITY_BUILD_PATH}/${BUILD_PREFIX}.loader.js?v=${UNITY_BUILD_VERSION}`