Skip to content

NullReferenceException in NetworkConnectionManager.cs when PlayerPrefab is not assigned #3964

Description

@Ceeeeed

In NGO version 2.11.1, a NullReferenceException is thrown in NetworkConnectionManager.cs at line 975 when PlayerPrefab is not assigned in the inspector.

Current code:

varidHashToSpawn=playerPrefabHash??NetworkManager.NetworkConfig.PlayerPrefab?.GetComponent<NetworkObject>()?.GlobalObjectIdHash;

Changing the code to the following fixes the issue:

varidHashToSpawn=playerPrefabHash;varplayerPrefab=NetworkManager.NetworkConfig.PlayerPrefab;if(idHashToSpawn==null&&playerPrefab!=null&&playerPrefab.TryGetComponent<NetworkObject>(outvarplayerNetworkObject))idHashToSpawn=playerNetworkObject.GlobalObjectIdHash;

After this change, everything works correctly even when PlayerPrefab is not assigned.

The exception occurs after calling:

NetworkManager.StartHost();

while using SinglePlayerTransport.

Environment:

  • NGO version: 2.11.1
  • Transport: SinglePlayerTransport
  • Unity version: 6000.3.11.f1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:highThis issue has high priority and we are focusing to resolve itregressionThe issue is a regression (something that was working in previous version)type:bugBug Report

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions