Error when start and when AI agents spawned

nRedux

Member
Surely, I've set something up wrong. Any ideas?

NullReferenceException: Object reference not set to an instance of an object
Opsive.UltimateCharacterController.Items.Item.IsActive () (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Item.cs:620)
Opsive.UltimateCharacterController.Items.Item.set_ShowFullScreenUI (System.Boolean value) (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Item.cs:134)
Opsive.UltimateCharacterController.Items.Item.Equip (System.Boolean immediateEquip) (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Item.cs:466)
Opsive.UltimateCharacterController.Inventory.InventoryBase.EquipItem (Opsive.UltimateCharacterController.Inventory.ItemType itemType, System.Int32 slotID, System.Boolean immediateEquip) (at Assets/Opsive/UltimateCharacterController/Scripts/Inventory/InventoryBase.cs:360)
Opsive.UltimateCharacterController.Character.Abilities.Items.EquipUnequip.OnPickupItem (Opsive.UltimateCharacterController.Items.Item item, System.Single count, System.Boolean immediatePickup, System.Boolean forceEquip) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/Items/EquipUnequip.cs:213)
Opsive.UltimateCharacterController.Events.InvokableAction`4[T1,T2,T3,T4].Invoke (T1 arg1, T2 arg2, T3 arg3, T4 arg4) (at Assets/Opsive/UltimateCharacterController/Scripts/Events/InvokableAction.cs:225)
Opsive.UltimateCharacterController.Events.EventHandler.ExecuteEvent[T1,T2,T3,T4] (System.Object obj, System.String eventName, T1 arg1, T2 arg2, T3 arg3, T4 arg4) (at Assets/Opsive/UltimateCharacterController/Scripts/Events/EventHandler.cs:522)
Opsive.UltimateCharacterController.Inventory.InventoryBase.ItemTypePickup (Opsive.UltimateCharacterController.Inventory.ItemType itemType, System.Single count, System.Int32 slotID, System.Boolean immediatePickup, System.Boolean forceEquip) (at Assets/Opsive/UltimateCharacterController/Scripts/Inventory/InventoryBase.cs:277)
Opsive.UltimateCharacterController.Inventory.InventoryBase.PickupItemType (Opsive.UltimateCharacterController.Inventory.ItemType itemType, System.Single count, System.Int32 slotID, System.Boolean immediatePickup, System.Boolean forceEquip, System.Boolean notifyOnPickup) (at Assets/Opsive/UltimateCharacterController/Scripts/Inventory/InventoryBase.cs:222)
Opsive.UltimateCharacterController.Inventory.InventoryBase.PickupItemType (Opsive.UltimateCharacterController.Inventory.ItemType itemType, System.Single count, System.Int32 slotID, System.Boolean immediatePickup, System.Boolean forceEquip) (at Assets/Opsive/UltimateCharacterController/Scripts/Inventory/InventoryBase.cs:194)
Opsive.UltimateCharacterController.Inventory.InventoryBase.LoadDefaultLoadout () (at Assets/Opsive/UltimateCharacterController/Scripts/Inventory/InventoryBase.cs:134)
Opsive.UltimateCharacterController.Inventory.InventoryBase.Start () (at Assets/Opsive/UltimateCharacterController/Scripts/Inventory/InventoryBase.cs:119)
 
What steps did you take to get that error? It looks like the item hasn't been initialized.
 
Set up my player character.
Just created a simple AI agent.
Added a weapon (item) third person only. Hit play.

The same error can be seen in the behaviordesigner integration first person demo scene.
 
The issue happens when in Item.IsActive() it attempts to call m_ActivePerspectiveItem.IsActive(), and m_ActivePerspectiveItem is null. As for why that is, you're right, it's probably not initialized somehow? How that comes to pass is above my pay grade atm.
 
Item.Start, here I see it trying to assign m_ActivePerspectiveItem, but in this case, when at line ~315 it checks m_CharacterLocomotion.FirstPersonPerspective and instead of assigning the m_ThirdPersonPerspectiveItem to the m_ActivePerspectiveItem, it chooses
m_FirstPersonPerspectiveItem.

Not sure if this helps, but something with the movement type being set up wrong? Tried looking but I don't much understand how the system works.

[edit]
this seems like an issue as I didn't set up anything first person on the agent, so perhaps it's attempting to utilize objects which don't exist as a result?
 
this seems like an issue as I didn't set up anything first person on the agent, so perhaps it's attempting to utilize objects which don't exist as a result?
Ah, yes, that would case it. For AI characters you only need to setup a third person perspective.
 
That's what I did, I only set up third person items. The BD shooter demo scene does throws the same error.
 
Good catch. You can fix this by changing line 315 within Item.cs from:

Code:
            if (m_CharacterLocomotion.FirstPersonPerspective

to:

Code:
            if (m_CharacterLocomotion.FirstPersonPerspective && m_FirstPersonPerspectiveItem != null

You'll then get an error indicating the movement type doesn't match but I'll upload a new Behavior Designer integration package that has it fixed (this relates to how I am building those scenes).
 
Top