Can't equip flashlight

matheussartori

New member
Hi Guys. I have created a flashlight item, a item collection and I'm using the Item category for the flashlight.

1701699789409.png

1701699836568.png

I have also created the flashlight pick up, and the pickup is working fine i guess, because I'm able to pick up the flashlight 3 times.

I'm receiving this error when I pick the flashlight or equip it on the default inventory:

Code:
The Character Item prefab at index 0 is null for Flashlight.
UnityEngine.Debug:LogError (object)
Opsive.UltimateCharacterController.Inventory.InventoryBase:SpawnItemIdentifiersCharacterItem (Opsive.Shared.Inventory.IItemIdentifier,int) (at Assets/Opsive/UltimateCharacterController/Scripts/Inventory/InventoryBase.cs:750)
Opsive.UltimateCharacterController.Inventory.InventoryBase:AddItemIdentifierAmount (Opsive.Shared.Inventory.IItemIdentifier,int,bool,int) (at Assets/Opsive/UltimateCharacterController/Scripts/Inventory/InventoryBase.cs:591)
Opsive.UltimateCharacterController.Inventory.InventoryBase:PickupItem (Opsive.Shared.Inventory.IItemIdentifier,int,int,bool,bool,bool,bool) (at Assets/Opsive/UltimateCharacterController/Scripts/Inventory/InventoryBase.cs:642)
Opsive.UltimateCharacterController.Inventory.InventoryBase:PickupItem (Opsive.Shared.Inventory.IItemIdentifier,int,int,bool,bool) (at Assets/Opsive/UltimateCharacterController/Scripts/Inventory/InventoryBase.cs:617)
Opsive.UltimateCharacterController.Objects.CharacterAssist.ItemPickup:DoItemIdentifierPickupInternal (UnityEngine.GameObject,Opsive.UltimateCharacterController.Inventory.InventoryBase,int,bool,bool) (at Assets/Opsive/UltimateCharacterController/Scripts/Objects/CharacterAssist/ItemPickup.cs:73)
Opsive.UltimateCharacterController.Objects.CharacterAssist.ItemPickupBase:DoItemIdentifierPickup (UnityEngine.GameObject,Opsive.UltimateCharacterController.Inventory.InventoryBase,int,bool,bool) (at Assets/Opsive/UltimateCharacterController/Scripts/Objects/CharacterAssist/ItemPickupBase.cs:136)
Opsive.UltimateCharacterController.Character.Abilities.Pickup:DoPickup () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/Pickup.cs:332)
Opsive.UltimateCharacterController.Utility.AnimationEventTrigger:NotifyEventListeners () (at Assets/Opsive/UltimateCharacterController/Scripts/Utility/AnimationEventTrigger.cs:169)
Opsive.UltimateCharacterController.Utility.AnimationEventTrigger:InvokeScheduledEvent () (at Assets/Opsive/UltimateCharacterController/Scripts/Utility/AnimationEventTrigger.cs:156)
Opsive.Shared.Game.ScheduledEvent:Invoke ()
Opsive.Shared.Game.SchedulerBase:Invoke (Opsive.Shared.Game.ScheduledEventBase,int)
Opsive.Shared.Game.SchedulerBase:FixedUpdate ()

I have reviewed the documentation, and I can't seem to find what's wrong. The idea is having one flashlight that every character can equip, so it's not bound to the default character on creation.

I'm using PUN as well, and the scene setup is working, the character is working as well. I also updated the pick up with the addon to add the PUN scripts.

The character is with the correct item collection too.

1701700036611.png

Any ideas of what could be wrong? Thanks in advice!
 

Attachments

  • 1701699894081.png
    1701699894081.png
    61.3 KB · Views: 1
Last edited:
I have managed to fix this. On the PunGame prefab, there's a script with the DemoCollectionItem, so i changed to my collection and it worked, but the error The Character Item prefab at index 0 is null for Flashlight. still happening
 
You should not have the FlashlightPickup in your prefab list - this list is only for the items that can spawn in the character's hand. @Cheo actually just released a tutorial showing how to setup the flashlight: https://opsive.com/forum/index.php?threads/new-tutorials-for-ucc3.10196/#post-50458
That's awesome, this tutorial will help a lot, thank you!

Removing the pick up prefab from the item collection also fixed the error.

I'm facing a issue now regarding the HDRP i believe.

When I apply the normal texture to the third person flashlight, it appears twice on my perspective. When I apply the invisible shader, I can't see the flashlight in other players hands (I'm using PUN). Any ideas of what I did wrong?
 
Top