CharacterItemAction Exception

Ok, so I downloaded the new patch and it worked, thanks guys, but I found a new bug where I can't use my weapon anymore. I made a new prefage, as well as puyying on the character, but no avail.

I downgraded to version 3 and it worked just fine, but not when I go back on 3.0.1.

Here is a video showing you guys the steps I made and also the console with all the errors :


I think the problem is somewhere in the inventory for what I can tell, like it can't process the item.
 
1. With First Person Controller v.3.0.1
2. With Unity v.2022.1.20f1
3. Null reference exception not set to an instance of an object after creating a new item.
4. a) Create a new Unity project
b) Install First person controller version 3.0.1
c) Create a new character
d) Create a new item type and a new item ( it doesn't matter if it's a prefab or on the character)
e) Test by going into game mode
f) Check the console tab
5) Here is the screenshot of the full error message (there is two) and a video showing the step

 

Attachments

  • Error.png
    Error.png
    319.5 KB · Views: 10
  • Error2.png
    Error2.png
    56.9 KB · Views: 10
I'm very sorry about that, turns out it is a silly mistake.
If the CharacterItem only has a single Action you will get an error becaise of this chunk of code on line 270 of the CharacItem.cs script
Code:
m_ItemActions = GetComponents<CharacterItemAction>();
if (m_ItemActions.Length > 1) {
    m_IDItemActionMap = new Dictionary<int, CharacterItemAction>();
    for (int i = 0; i < m_ItemActions.Length; ++i) {
        m_IDItemActionMap.Add(m_ItemActions[i].ID, m_ItemActions[i]);
        m_ItemActions[i].InitializeAction(false);
    }
}

Remove that if condition to end up with
Code:
m_IDItemActionMap = new Dictionary<int, CharacterItemAction>();
for (int i = 0; i < m_ItemActions.Length; ++i) {
    m_IDItemActionMap.Add(m_ItemActions[i].ID, m_ItemActions[i]);
    m_ItemActions[i].InitializeAction(false);
}
 
Top