-
Notifications
You must be signed in to change notification settings - Fork 459
NetworkSpawnManager.GetLocalPlayerObject only works on host #580
Copy link
Copy link
Closed
Labels
good-first-issueContributions are welcome. Good first issue for newcomers or first time contributors.Contributions are welcome. Good first issue for newcomers or first time contributors.type:bugBug ReportBug Report
Description
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
good-first-issueContributions are welcome. Good first issue for newcomers or first time contributors.Contributions are welcome. Good first issue for newcomers or first time contributors.type:bugBug ReportBug Report