3rd person Runtime pickup index out of range

tuirennder

New member
Hello!

I have a weird issue where runtime pickup only works for my melee weapon when I set a _wrong_ item collection in the Item Set Manager.

Working setup:

TPC_pickup_working.JPG


As you can see above, the item type Sword_demo_type that I use everywhere is not in the collection I reference in the Item Set Manager. I also manually populate
the Item Set 0.

Surprisingly, like this it works, the sword is equiped and usable without errors:

TPC_pickup_working_2.JPG


Now if I try to do what I believe is the good way, using the correct item collection and leaving the Item Set empty:


TPC_pickup_not_working.JPG


... after going through the pickup item, I get this index out of range error:

Code:
IndexOutOfRangeException: Array index is out of range.
Opsive.UltimateCharacterController.Inventory.ItemSetManager.GetEquipItemType (Int32 categoryIndex, Int32 targetItemSetIndex, Int32 slot) (at Assets/Opsive/UltimateCharacterController/Scripts/Inventory/ItemSetManager.cs:465)
Opsive.UltimateCharacterController.Character.Abilities.Items.EquipUnequip.Update () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/Items/EquipUnequip.cs:488)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.UpdateAbilities (Opsive.UltimateCharacterController.Character.Abilities.Ability[] abilities) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:716)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.UpdateUltimateLocomotion () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:643)
Opsive.UltimateCharacterController.Character.CharacterLocomotion.Move (Single horizontalMovement, Single forwardMovement, Single deltaYawRotation) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/CharacterLocomotion.cs:455)
Opsive.UltimateCharacterController.Game.DeterministicObjectManager+DeterministicCharacter.FixedMove () (at Assets/Opsive/UltimateCharacterController/Scripts/Game/DeterministicObjectManager.cs:146)
Opsive.UltimateCharacterController.Game.DeterministicObjectManager.FixedUpdate () (at Assets/Opsive/UltimateCharacterController/Scripts/Game/DeterministicObjectManager.cs:589)

We see the prefab added to the character, we see the item in the inventory, but the prefab remains inactive:

TPC_pickup_not_working_2.JPG


Thanks for reading. I can share the scene if needed.
 
That doesn't sound right. Can you send me a PM with your scene and item collection that is causing the error?
 
OK I found my mistake!
In the pickup gameobject, I have set the Slot Count to 1, assuming that with a single-handed weapon the empty Slot 1 was not needed:

TPC_pickup_mistake.JPG

Thanks!
 
Ahh, I see. Yeah, that will cause issues. I'll add a check for too high of a slot number so it won't at least thrown an error.
 
Top