Describe the bug
NetworkSpawnManager.GetLocalPlayerObject only works on host. A client calling this function will always return null.
To Reproduce
Steps to reproduce the behavior:
- Use a MLAPI project which uses player prefabs
- Call NetworkSpawnManager.GetLocalPlayer as the client
Expected behavior
NetworkSpawnManager.GetLocalPlayer should give me my local player object as the client.
Environment (please complete the following information):
- MLAPI Version: release/0.1.0
Additional context
Code for GetLocalPlayerObject is:
public static NetworkObject GetLocalPlayerObject()
{
if (!NetworkManager.Singleton.ConnectedClients.ContainsKey(NetworkManager.Singleton.LocalClientId)) return null;
return NetworkManager.Singleton.ConnectedClients[NetworkManager.Singleton.LocalClientId].PlayerObject;
}
But ConnectedClients as indicated by its XML doc is only populated on the server. I talked with Albin about this and one solution which we figured makes sense would be to polulate ConnectedClients with the own local client upon connection.
Describe the bug
NetworkSpawnManager.GetLocalPlayerObject only works on host. A client calling this function will always return null.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
NetworkSpawnManager.GetLocalPlayer should give me my local player object as the client.
Environment (please complete the following information):
Additional context
Code for GetLocalPlayerObject is:
But ConnectedClients as indicated by its XML doc is only populated on the server. I talked with Albin about this and one solution which we figured makes sense would be to polulate ConnectedClients with the own local client upon connection.