Add NGO networking with owner-authoritative player position sync
Install Netcode for GameObjects 2.13.0 + Unity Transport 2.6.0 and wire up the first networking milestone: syncing player position/rotation across clients. - NetworkBootstrap: Host/Client/Server controls (OnGUI + H/C hotkeys) for local clone testing over loopback 127.0.0.1:7777. - NetworkPlayerSetup: per-avatar owner gating. The local owner binds the GameModeManager and cameras to itself; remote avatars disable their controller/CharacterController and receive transform via NetworkTransform. - GameModeManager.BindLocalPlayer: central runtime rebind to the locally spawned player. - FirstPersonController.SetPlayer: explicit runtime rebind hook. - Player prefab: NetworkObject + NetworkTransform (owner-authoritative, position + rotation) + NetworkPlayerSetup; registered as PlayerPrefab. - Scene: NetworkManager + UnityTransport added; the fixed scene player instance removed in favor of spawn-on-connect. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
c0ec65058b
commit
4fa443f630
13 files changed
+435
-91
No files matched your search
@@ -175,6 +175,22 @@ public class FirstPersonController : MonoBehaviour
|
||||
if (r) r.enabled = !hidden;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Explicitly binds this rig to the locally-owned networked player (overriding the scene-wide
|
||||
/// auto-resolve, which could otherwise latch onto a remote avatar). Called by the GameModeManager
|
||||
/// when the local player spawns.
|
||||
/// </summary>
|
||||
public void SetPlayer(PlayerCharacterController p)
|
||||
{
|
||||
if (!p) return;
|
||||
_player = p;
|
||||
_poseController = p.GetComponent<PlayerPoseController>();
|
||||
Transform t = p.transform.Find("CameraTarget");
|
||||
if (t) cameraTarget = t;
|
||||
hiddenRenderers = p.GetComponentsInChildren<SkinnedMeshRenderer>(true);
|
||||
_resolved = true;
|
||||
}
|
||||
|
||||
void ResolveReferences()
|
||||
{
|
||||
if (_resolved) return;
|
||||
|
||||
Reference in new issue
Block a user