NullReferenceException inside the ThrowableItem Start() method

Hi all,

I have a strange issue. Whenever I spawn in my agents, I get this NullReferenceException inside the console window:
NullReferenceException: Object reference not set to an instance of an object
Opsive.UltimateCharacterController.Items.Actions.ThrowableItem.Start () (at Assets/Plugins/Opsive/UltimateCharacterController/Scripts/Items/Actions/ThrowableItem.cs:212)
The issue seems to be happening at this line:
m_Object = perspectiveItem.GetVisibleObject();

I double-checked all of the visible objects for the grenades and they have all been assigned to the ThirdPersonPerspectiveItem. Any ideas what could be causing this? Thank you :)
 
I think the perspectiveItem variable is null, so you need to check what happens in line 211.
Hi Christian,

At line 211, m_CharacterLocomotion.FirstPersonPerspective is returning true, meaning that the m_Item.FirstPersonPerspectiveItem component is being assigned to perspectiveItem. The agent only uses the ThirdPersonPerspectiveItem, so maybe that's why it's null. It's only the grenades that are showing this error, none of the other weapons are showing this error :unsure:
 
Ok, so I managed to fix this by referencing m_Item.ThirdPersonPerspectiveItem directly like so:

m_Object = m_Item.ThirdPersonPerspectiveItem.GetVisibleObject();

Should this problem even be happening to begin with? I'm using UFPC with Deathmatch AI, but NavMesh agents can still be created and they clearly are working. I have checked the demo agent prefab, and it is also using a ThirdPersonPerspectiveItem. Have I missed something in my setup, maybe an option that I didn't enable? Surely I shouldn't have to comment out a line to make this work.
 
The weapons/items for the agent should only have the third person components on them.
That's the thing, all of the weapons are only using third person components, yet for some reason, m_CharacterLocomotion.FirstPersonPerspective is returning true and the perspective item becomes null, since I don't have any first person perspective components attached to any of the items, so I have to manually assign a third person visible object.
 
Can you reproduce the issue with a fresh project? I just tried creating a new agent and the FirstPersonPerspective value returned false.
 
Top