[Bug] Nulled Reference Exception from Item Equip Verifier caused by Height Change and Speed Change

Cheo

Active member
Hello, this one took me a ridiculous amount of time to reproduce in a clean project, I hope it will get the attention it deserves ! Once again, this is one of those complicated issues that you can only stumble upon if you're making an actual game, so please bear with me ! Here's a video that shows all the required steps to get an error from Item Equip Verifier when trying to unequip a weapon when starting the Crawl ability, while also using the state system to enable Speed Change abilities :


As usual here's the stack and source :

C#:
[Exception] NullReferenceException: Object reference not set to an instance of an object
ItemEquipVerifier.ShouldStopActiveAbility() at /Opsive/UltimateCharacterController/Scripts/Character/Abilities/ItemEquipVerifier.cs:254
 252:          return false;
 253:      }
--> 254:      return m_StartingAbility.ShouldStopActiveAbility(activeAbility) || m_StartingAbility.Index < activeAbility.Index;
 255:  }

UltimateCharacterLocomotion.TryStartAbility() at /Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:888
 886:  // The ability can start. Stop any currently active abilities that should not be started because the current ability has started.
 887:  for (int i = m_ActiveAbilityCount - 1; i >= 0; --i) {
--> 888:      if (ability.ShouldStopActiveAbility(m_ActiveAbilities[i])) {
 889:          TryStopAbility(m_ActiveAbilities[i], true);
 890:      }

Ability.StartAbility() at /Opsive/UltimateCharacterController/Scripts/Character/Abilities/Ability.cs:453
 451:  public bool StartAbility()
 452:  {
--> 453:      return m_CharacterLocomotion.TryStartAbility(this);
 454:  }

ItemEquipVerifier.TryToggleItem() at /Opsive/UltimateCharacterController/Scripts/Character/Abilities/ItemEquipVerifier.cs:193
 191:          StartEquipUnequip(false);
 192:      } else {
--> 193:          StartAbility();
 194:      }
 195:  } else if (startPossible && activate && IsActive && m_StartingAbility != null && m_StartingAbility != ability) {

UltimateCharacterLocomotion.TryStartAbility() at /Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:918
 916:  // If TryToggleItem returns true then the ItemEquipVerifier ability has started and it will start the original ability after
 917:  // the character has finished unequipping the equipped items.
--> 918:  if (m_ItemEquipVerifierAbility.TryToggleItem(ability, true) && !ability.ImmediateStartItemVerifier) {
 919:      moveEquipStarted = true;
 920:  }

UltimateCharacterLocomotionHandler.TryStartAbility() at /Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotionHandler.cs:226
 224:  protected virtual bool TryStartAbility(Ability ability)
 225:  {
--> 226:      return m_CharacterLocomotion.TryStartAbility(ability);
 227:  }

UltimateCharacterLocomotionHandler.UpdateAbilityInput() at /Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotionHandler.cs:133
 131:      // they are still running (such as toggling an equipped item while waiting for the animation to do the equip).
 132:      if (abilities[i].CanInputStartAbility(m_PlayerInput)) {
--> 133:          TryStartAbility(abilities[i]);
 134:      }
 135:  }

UltimateCharacterLocomotionHandler.UpdateAbilityInput() at /Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotionHandler.cs:100
  99:      // Update the input for both the regular abilities and item abilities.
--> 100:      UpdateAbilityInput(m_CharacterLocomotion.Abilities);
 101:      UpdateAbilityInput(m_CharacterLocomotion.ItemAbilities);
 102:  }

UltimateCharacterLocomotionHandler.Update() at /Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotionHandler.cs:75
  73:  protected virtual void Update()
  74:  {
-->  75:      UpdateAbilityInput();
  76:  }

Hope this can be fixed, thanks in advance. And if I don't post anything tomorrow, happy new year in advance to everyone <3
 
I just tried following along with the video but wasn't able to reproduce the exception. Can you send the test scene that you are using so I can more easily reproduce it? Thank you!
 
I just checked a fix package from Justin and the error is gone now, for anyone reading this it should be okay in the next update !
 
Top