issue with firing and moving in Pun

Mattyfiller

New member
hi i was trying to add projectiles to my guns and after adding the projectile to the punpool i was having some issues while firing the guns for instance while moving backwards and firing at the same time the gun would lock up and fire the remain ammo left in the clip. after reloading with would do the same here is the error i would get when this is happening.

ArgumentException: An item with the same key has already been added. Key: bulletT(Clone) (UnityEngine.GameObject)
System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <fb001e01371b4adca20013e0ac763896>:0)
System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) (at <fb001e01371b4adca20013e0ac763896>: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.ShootableWeapon.ProjectileFire (System.Single strength) (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Actions/ShootableWeapon.cs:808)
Opsive.UltimateCharacterController.Items.Actions.ShootableWeapon.Fire (System.Single strength) (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Actions/ShootableWeapon.cs:740)
Opsive.UltimateCharacterController.Items.Actions.ShootableWeapon.UseItem () (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Actions/ShootableWeapon.cs:660)
Opsive.UltimateCharacterController.Character.Abilities.Items.Use.LateUpdate () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/Items/Use.cs:632)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.LateUpdateActiveAbilities (Opsive.UltimateCharacterController.Character.Abilities.Ability[] abilities, System.Int32& abilityCount) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:1025)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.LateUpdateUltimateLocomotion () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:1011)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.UpdatePositionAndRotation () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:826)
Opsive.UltimateCharacterController.Character.CharacterLocomotion.UpdatePositionAndRotation (System.Boolean fromAnimatorMove) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/CharacterLocomotion.cs:517)
Opsive.UltimateCharacterController.Character.CharacterLocomotion.OnAnimatorMove () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/CharacterLocomotion.cs:1470)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.OnAnimatorMove () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:1753)
 
other error that comes up

ArgumentNullException: Value cannot be null.
Parameter name: key
System.Collections.Generic.Dictionary`2[TKey,TValue].FindEntry (TKey key) (at <fb001e01371b4adca20013e0ac763896>:0)
System.Collections.Generic.Dictionary`2[TKey,TValue].TryGetValue (TKey key, TValue& value) (at <fb001e01371b4adca20013e0ac763896>:0)
Opsive.Shared.Game.GameObjectExtensions.GetCachedComponent[T] (UnityEngine.GameObject gameObject) (at <6384e96c23454da4916708c025edc3a8>:0)
Opsive.UltimateCharacterController.AddOns.Multiplayer.PhotonPun.Objects.PunProjectile.SpawnData () (at Assets/Opsive/UltimateCharacterController/Add-Ons/Multiplayer/PhotonPUN/Scripts/Objects/PunProjectile.cs:39)
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:129)
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.ShootableWeapon.ProjectileFire (System.Single strength) (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Actions/ShootableWeapon.cs:808)
Opsive.UltimateCharacterController.Items.Actions.ShootableWeapon.Fire (System.Single strength) (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Actions/ShootableWeapon.cs:740)
Opsive.UltimateCharacterController.Items.Actions.ShootableWeapon.UseItem () (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Actions/ShootableWeapon.cs:660)
Opsive.UltimateCharacterController.Character.Abilities.Items.Use.LateUpdate () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/Items/Use.cs:632)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.LateUpdateActiveAbilities (Opsive.UltimateCharacterController.Character.Abilities.Ability[] abilities, System.Int32& abilityCount) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:1025)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.LateUpdateUltimateLocomotion () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:1011)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.UpdatePositionAndRotation () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:826)
Opsive.UltimateCharacterController.Character.CharacterLocomotion.UpdatePositionAndRotation (System.Boolean fromAnimatorMove) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/CharacterLocomotion.cs:517)
Opsive.UltimateCharacterController.Character.CharacterLocomotion.OnAnimatorMove () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/CharacterLocomotion.cs:1470)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.OnAnimatorMove () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:1753)
 
Ok think a narrowed it down a bit more i think that the projectiles are hitting each other causing the bug just not sure how to fix it

MissingReferenceException: The object of type 'PunProjectile' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
Opsive.UltimateCharacterController.Objects.TrajectoryObject.InitializeComponentReferences () (at Assets/Opsive/UltimateCharacterController/Scripts/Objects/TrajectoryObject.cs:478)
Opsive.UltimateCharacterController.Objects.Destructible.OnCollision (System.Nullable`1[T] hit) (at Assets/Opsive/UltimateCharacterController/Scripts/Objects/Destructible.cs:201)
Opsive.UltimateCharacterController.Objects.Projectile.OnCollision (System.Nullable`1[T] hit) (at Assets/Opsive/UltimateCharacterController/Scripts/Objects/Projectile.cs:64)
Opsive.UltimateCharacterController.Objects.Projectile.Deactivate () (at Assets/Opsive/UltimateCharacterController/Scripts/Objects/Projectile.cs:51)
Opsive.Shared.Game.ScheduledEvent.Invoke () (at <6384e96c23454da4916708c025edc3a8>:0)
Opsive.Shared.Game.SchedulerBase.Invoke (Opsive.Shared.Game.ScheduledEventBase scheduledEvent, System.Int32 index) (at <6384e96c23454da4916708c025edc3a8>:0)
Opsive.Shared.Game.SchedulerBase.Update () (at <6384e96c23454da4916708c025edc3a8>:0)
 
Are you able to tell me how to reproduce the error within the demo scene of a fresh project, after making the change from the other thread?
 
Top