InventoryItemVisualizer and PrefabAttributeName Error

JohnG

Member
Hi,

I am getting an error when I am trying to do pickups (following integration part 1, 33 min mark). I am using the InventoryItemPickup method (1st method in tutorial).

If I leave the Prefab Attribute name blank (Image 1), I don't get any errors, however the real pickup visual is not shown, so it reverts to default visual (this is what I would expect). When you play, the Prefab Attribute Name defaults to PickupPrefab.

Capture.PNG

The way I want it to work is exactly how you are doing it in the tutorial, so I set the Prefab Attribute name to DropPrefab, however when I press play I get 4 errors (ill just post one of them for now):

NullReferenceException: Object reference not set to an instance of an object
Opsive.UltimateCharacterController.Items.Actions.ItemAction.Awake () (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Actions/ItemAction.cs:59)
Opsive.UltimateCharacterController.Items.Actions.UsableItem.Awake () (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Actions/UsableItem.cs:124)
Opsive.UltimateCharacterController.Items.Actions.ShootableWeapon.Awake () (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Actions/ShootableWeapon.cs:375)
UnityEngine.Object:Instantiate(GameObject, Vector3, Quaternion, Transform)
Opsive.Shared.Game.ObjectPoolBase:InstantiateInternal(GameObject, Int32, Vector3, Quaternion, Transform)
Opsive.Shared.Game.ObjectPoolBase:InstantiateInternal(GameObject, Vector3, Quaternion, Transform)
Opsive.Shared.Game.ObjectPoolBase:Instantiate(GameObject, Vector3, Quaternion, Transform)
Opsive.Shared.Game.ObjectPoolBase:Instantiate(GameObject, Transform)
Opsive.UltimateInventorySystem.DropsAndPickups.ItemVisualizerBase:SetVisualInternal(ItemInfo) (at Assets/Opsive/UltimateInventorySystem/Scripts/DropsAndPickups/ItemVisualizerBase.cs:152)
Opsive.UltimateInventorySystem.DropsAndPickups.ItemVisualizerBase:UpdateVisual(ItemInfo) (at Assets/Opsive/UltimateInventorySystem/Scripts/DropsAndPickups/ItemVisualizerBase.cs:89)
Opsive.UltimateInventorySystem.DropsAndPickups.InventoryItemVisualizer:UpdateVisual() (at Assets/Opsive/UltimateInventorySystem/Scripts/DropsAndPickups/InventoryItemVisualizer.cs:78)
Opsive.UltimateInventorySystem.DropsAndPickups.ItemVisualizerBase:OnEnable() (at Assets/Opsive/UltimateInventorySystem/Scripts/DropsAndPickups/ItemVisualizerBase.cs:74)
Opsive.UltimateInventorySystem.DropsAndPickups.InventoryItemVisualizer:OnEnable() (at Assets/Opsive/UltimateInventorySystem/Scripts/DropsAndPickups/InventoryItemVisualizer.cs:48)

Here are two images that show the InventoryItemVisualizer and my item definition.

Capture2.PNG
Capture3.PNG

I have UCC 2.3.2 UIS 1.1.7 and latest integration.

Do you know what the issue is?
 
My guess is that your DropPrefab prefab has Character Controller Item scripts on it. Most of these scripts require that prefab to be spawned through the Character Controller system, on the character.

This is one of the reason you seperate the "Prefab" from the "Drop Prefab".
The easiest solution is to make a prefab variant of your weapon that has the weapon scripts, and another that is just the model with materials and perhaps some colliders.
Make sure that the DropPrefab does not have any Weapon or Item scripts on it (except custom ones you which to add of course)

I hope this helps
 
Hi,

Found the issue so posting incase anyone else has this problem.

The mistake is quite subtle. I should have been using the model and not the prefab of the weapon.

Capture5.PNG

Look at the override Value icon (This one is the prefab. The next image show the model (the correct setting)

Capture4.PNG
 
Top