Closed luishnc closed 1 year ago
NGO 1.5.1 Method Singleton.ConnectedClients[clientID].OwnedObjects not working anymore.
1 Sample class that Spawin with ownership:
public void SpawnTestServerRpc(ServerRpcParams serverRpcParams = default) {
//assign transform to the Sender parent transform var clientID = serverRpcParams.Receive.SenderClientId; if (NetworkManager.Singleton.ConnectedClients.ContainsKey(clientID)) { var client = NetworkManager.ConnectedClients[clientID]; //var client = NetworkManager.Singleton.ConnectedClients.ContainsKey(clientID); Transform clientTransform = NetworkManager.ConnectedClients[clientID].PlayerObject.transform.GetComponent<Transform>(); Debug.Log("Client: " + clientID + " Spawned Muffin"); foreach (Transform t in creatureListPrefab) { Debug.Log("Trying to spawn Muffin"); Transform spawnedObjectTransform = Instantiate(t); spawnedObjectTransform.GetComponent<NetworkObject>().SpawnWithOwnership(client.ClientId); } } }
Sample method showing that OwnedObjects is broken:
[ServerRpc(RequireOwnership = false)] private void AssignAttackedCreatureServerRpc(NetworkObjectReference enemyObjectReference, ServerRpcParams serverRpcParams = default) { enemyObjectReference.TryGet(out NetworkObject enemyNetworkObject);
var clientID = serverRpcParams.Receive.SenderClientId; if (NetworkManager.Singleton.ConnectedClients.ContainsKey(clientID)) { var client = NetworkManager.ConnectedClients[clientID]; Debug.Log("Trying to set tartget creature. Owned objects: " + NetworkManager.Singleton.ConnectedClients[clientID].OwnedObjects.Count); foreach (NetworkObject netObj in NetworkManager.Singleton.ConnectedClients[clientID].OwnedObjects) { if (netObj.TryGetComponent<CreatureAI>(out CreatureAI dcClientsCreatureAI)) { dcClientsCreatureAI.SetTargetPosition(enemyNetworkObject.transform); } } }
}
OwnedObjects.count = 0
OwnedObjects.count = 1
I tested with NGO 1.2.0, 1.31 and 1.4.0 and they all are working as expected.
@luishnc This will be fixed in the up-coming patch. Thank you for reporting this issue! 👍
@NoelStephensUnity cool, thanks Noel for the fast response 👍
Description
NGO 1.5.1 Method Singleton.ConnectedClients[clientID].OwnedObjects not working anymore.
Reproduce Steps
1 Sample class that Spawin with ownership:
public void SpawnTestServerRpc(ServerRpcParams serverRpcParams = default) {
Sample method showing that OwnedObjects is broken:
[ServerRpc(RequireOwnership = false)] private void AssignAttackedCreatureServerRpc(NetworkObjectReference enemyObjectReference, ServerRpcParams serverRpcParams = default) { enemyObjectReference.TryGet(out NetworkObject enemyNetworkObject);
}
Actual Outcome
OwnedObjects.count = 0
Expected Outcome
OwnedObjects.count = 1
Environment
Additional Context
I tested with NGO 1.2.0, 1.31 and 1.4.0 and they all are working as expected.