ChristianWiele
Active member
Hi,
I created a throwable object (coconut) with a corresponding pickup. The player can pick up the coconut and throw it. On collision, the coconut is destroyed. The pickup is automatically respawned. The pickup / throwable have been set up with PUN. The throwable is of type grenade as I want an effect to be spawned upon collision / destruction.
I have two players (server and client). If I pickup the coconut on the server, everything is fine. I can pickup and throw the coconut multiple times. If I do the same on the client, everything works fine for the first time. If I throw the coconut for the second time, I get the exception below (on the server). As a result, the throwable coconut is spawned only on the server, but not on the client. Seems that something with the pooling goes wrong!?
Regards, Christian
ArgumentException: An item with the same key has already been added. Key: CoconutThrowableObject Variant PUN(Clone) (UnityEngine.GameObject)
System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <9577ac7a62ef43179789031239ba8798>:0)
System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) (at <9577ac7a62ef43179789031239ba8798>:0)
Opsive.UltimateCharacterController.AddOns.Multiplayer.PhotonPun.Game.PunObjectPool.NetworkSpawnInternal (UnityEngine.GameObject original, UnityEngine.GameObject instanceObject, System.Boolean sceneObject) (at Assets/Opsive/UltimateCharacterController/Add-Ons/Multiplayer/PhotonPUN/Scripts/Game/PunObjectPool.cs:118)
Opsive.UltimateCharacterController.Networking.Game.NetworkObjectPool.NetworkSpawn (UnityEngine.GameObject original, UnityEngine.GameObject instanceObject, System.Boolean sceneObject) (at Assets/Opsive/UltimateCharacterController/Scripts/Networking/NetworkObjectPool.cs:53)
Opsive.UltimateCharacterController.Items.Actions.ThrowableItem.ThrowItem () (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Actions/ThrowableItem.cs:536)
Opsive.UltimateCharacterController.AddOns.Multiplayer.PhotonPun.Character.PunCharacter.ThrowItemRPC (System.Int32 slotID, System.Int32 actionID) (at Assets/Opsive/UltimateCharacterController/Add-Ons/Multiplayer/PhotonPUN/Scripts/Character/PunCharacter.cs:655)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <9577ac7a62ef43179789031239ba8798>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <9577ac7a62ef43179789031239ba8798>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <9577ac7a62ef43179789031239ba8798>:0)
Photon.Pun.PhotonNetwork.ExecuteRpc (ExitGames.Client.Photon.Hashtable rpcData, Photon.Realtime.Player sender) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:540)
Photon.Pun.PhotonNetwork.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:2160)
Photon.Realtime.LoadBalancingClient.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:3253)
ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer stream) (at <55327f06489f4ebdb665a4707c165dbb>:0)
ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands () (at <55327f06489f4ebdb665a4707c165dbb>:0)
ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands () (at <55327f06489f4ebdb665a4707c165dbb>:0)
Photon.Pun.PhotonHandler.Dispatch () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:223)
Photon.Pun.PhotonHandler.FixedUpdate () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:149)
I created a throwable object (coconut) with a corresponding pickup. The player can pick up the coconut and throw it. On collision, the coconut is destroyed. The pickup is automatically respawned. The pickup / throwable have been set up with PUN. The throwable is of type grenade as I want an effect to be spawned upon collision / destruction.
I have two players (server and client). If I pickup the coconut on the server, everything is fine. I can pickup and throw the coconut multiple times. If I do the same on the client, everything works fine for the first time. If I throw the coconut for the second time, I get the exception below (on the server). As a result, the throwable coconut is spawned only on the server, but not on the client. Seems that something with the pooling goes wrong!?
Regards, Christian
ArgumentException: An item with the same key has already been added. Key: CoconutThrowableObject Variant PUN(Clone) (UnityEngine.GameObject)
System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <9577ac7a62ef43179789031239ba8798>:0)
System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) (at <9577ac7a62ef43179789031239ba8798>:0)
Opsive.UltimateCharacterController.AddOns.Multiplayer.PhotonPun.Game.PunObjectPool.NetworkSpawnInternal (UnityEngine.GameObject original, UnityEngine.GameObject instanceObject, System.Boolean sceneObject) (at Assets/Opsive/UltimateCharacterController/Add-Ons/Multiplayer/PhotonPUN/Scripts/Game/PunObjectPool.cs:118)
Opsive.UltimateCharacterController.Networking.Game.NetworkObjectPool.NetworkSpawn (UnityEngine.GameObject original, UnityEngine.GameObject instanceObject, System.Boolean sceneObject) (at Assets/Opsive/UltimateCharacterController/Scripts/Networking/NetworkObjectPool.cs:53)
Opsive.UltimateCharacterController.Items.Actions.ThrowableItem.ThrowItem () (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Actions/ThrowableItem.cs:536)
Opsive.UltimateCharacterController.AddOns.Multiplayer.PhotonPun.Character.PunCharacter.ThrowItemRPC (System.Int32 slotID, System.Int32 actionID) (at Assets/Opsive/UltimateCharacterController/Add-Ons/Multiplayer/PhotonPUN/Scripts/Character/PunCharacter.cs:655)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <9577ac7a62ef43179789031239ba8798>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <9577ac7a62ef43179789031239ba8798>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <9577ac7a62ef43179789031239ba8798>:0)
Photon.Pun.PhotonNetwork.ExecuteRpc (ExitGames.Client.Photon.Hashtable rpcData, Photon.Realtime.Player sender) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:540)
Photon.Pun.PhotonNetwork.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:2160)
Photon.Realtime.LoadBalancingClient.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:3253)
ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer stream) (at <55327f06489f4ebdb665a4707c165dbb>:0)
ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands () (at <55327f06489f4ebdb665a4707c165dbb>:0)
ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands () (at <55327f06489f4ebdb665a4707c165dbb>:0)
Photon.Pun.PhotonHandler.Dispatch () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:223)
Photon.Pun.PhotonHandler.FixedUpdate () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:149)