DeterimneWeapon.OnUpdate error :(

HamsterHam

New member
So I followed the DeathMatch AI Kit tutorial from Youtube, scoured the documentation and burned my day off of work trying to solve this issue.
After setting up everything exactly as it is on the video with the exception of the 3D models used for the assault rifle, and me adding bullets on the inventory script, I get the following error:
NullReferenceException: Object reference not set to an instance of an object
Opsive.DeathmatchAIKit.AI.Actions.DetermineWeapon.OnUpdate () (at Assets/Opsive/DeathmatchAIKit/Scripts/AI/Actions/Attack/DetermineWeapon.cs:108)

It happens as soon as the AI agent detects me.

It does not happen if I disable the weapon on the AI agent, at which point it just runs at me since I havent set up any other type of attack

Does anyone know why?
 
Last edited:
That line points to:

Code:
                if (m_Inventory.GetItemIdentifierAmount(m_WeaponPool[i].Item.ItemIdentifier) == 0) {
If you insert a breakpoint or Debug.Log, what is null?
 
Hi and thank you for your reply, after placing a breakpoint at the indicated line of code, the null values are:
primaryWeaponStat
secondaryWeaponStat
meleeWeaponStat
and weaponStat
 
Hello, I don't have the same thing at around line 108 of Attack, however if these stats are null I'm assuming you have an empty list here in Deathmatch Agent, or at least an improperly setup one :

Capture d’écran (3526).png

Lemme know if this helps.
 
Hello, I don't have the same thing at around line 108 of Attack, however if these stats are null I'm assuming you have an empty list here in Deathmatch Agent, or at least an improperly setup one :

View attachment 14194

Lemme know if this helps.
Hey Cheo, I had already checked that and it is populated with the one weapon Ive given this test enemy, so I dont think its that unfortunately.
Thanks for the suggestion though :).
 
The weapon stats aren't causing the exception - it's one of the object references in the line that is throwing the error. It'll either be m_Inventory, m_WeaponPool, m_WeaponPool.Item, or m_WeaponPool.Item.ItemIdentifier.
 
Back
Top