BUG: kill character on reload (MissingReferenceException ReloadableClip)

anisimov

New member
1. Ultimate Character Controller 2.4.8
2. Unity 2021.3.5
3. If you kill a character while reloading at a certain point, his weapon drops out of inventory, but the reload does not end, which causes MissingReferenceException
4. Steps
1) Create an agent with the demo pistol
2) Make him shoot (no matter where)
3) Kill him (better make health = 1 so you can kill quickly) when he starts reloading and the reloadable clip is detached
4) Bug... Error in the console, weapons drop from the inventory, but the bot remains "alive" (I think due to the fact that something is not called due to Null Reference Exception)

5. The full error message:

MissingReferenceException: The object of type 'Transform' 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.
UnityEngine.Transform.get_position () (at <4a31731933e0419ca5a995305014ad37>:0)
Opsive.UltimateCharacterController.Items.Actions.ShootableWeapon.AddRemoveReloadableClip (System.Boolean add, Opsive.UltimateCharacterController.Items.Actions.PerspectiveProperties.IShootableWeaponPerspectiveProperties shootableWeaponPerspectiveProperties, System.Boolean firstPerson) (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Actions/ShootableWeapon.cs:1640)
Opsive.UltimateCharacterController.Items.Actions.ShootableWeapon.ReloadItem (System.Boolean fullClip) (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Actions/ShootableWeapon.cs:1610)
Opsive.UltimateCharacterController.Character.Abilities.Items.Reload.ReloadItem (System.Int32 slotID) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/Items/Reload.cs:370)
Opsive.UltimateCharacterController.Character.Abilities.Items.Reload.OnItemReload () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/Items/Reload.cs:319)
Opsive.Shared.Events.InvokableAction.Invoke () (at <c8e5381e72fc4f3ba22ae5029e6e4da1>:0)
Opsive.Shared.Events.EventHandler.ExecuteEvent (System.Object obj, System.String eventName) (at <c8e5381e72fc4f3ba22ae5029e6e4da1>:0)
Opsive.UltimateCharacterController.Character.AnimatorMonitor.ExecuteEvent (System.String eventName) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/AnimatorMonitor.cs:940)

Video:
 
Last edited:
Thanks, that line likely needs a null check. I'll look at this and have it fixed before the next update.
 
Top