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:
@@ -116,12 +116,12 @@ public class DebugNetworkUI : MonoBehaviour
|
||||
if (state != null)
|
||||
ImGuiSkin.DrawField("Server Pos", $"({state.x:F1}, {state.y:F1}, {state.z:F1})");
|
||||
|
||||
var pc = FindFirstObjectByType<PlayerController>();
|
||||
if (pc != null && pc.isActiveAndEnabled)
|
||||
var vehicle = FindFirstObjectByType<NWH.VehiclePhysics2.VehicleController>();
|
||||
if (vehicle != null && vehicle.isActiveAndEnabled)
|
||||
{
|
||||
var pos = pc.transform.position;
|
||||
var pos = vehicle.transform.position;
|
||||
ImGuiSkin.DrawField("Live Pos", $"({pos.x:F1}, {pos.y:F1}, {pos.z:F1})");
|
||||
var rb = pc.GetComponent<Rigidbody>();
|
||||
var rb = vehicle.vehicleRigidbody;
|
||||
if (rb != null)
|
||||
{
|
||||
var v = rb.linearVelocity;
|
||||
|
||||
Reference in New Issue
Block a user