SlotID cannot be set to -1.

Hello Opsive!

I created a custom ability to suit my system. I decided to stop it manually. I have aniation event that invokes in method this:
characterLocomotion.TryStartAbility(targetAbility);

Basically it works fine, but when I first time I use ability I soon receive a warning repeated a couple of times:
characterLocomotion.TryStartAbility(targetSpellAbility);

SlotID cannot be set to -1.
UnityEngine.Debug:LogWarning (object)
Opsive.UltimateCharacterController.Character.Abilities.Items.ItemAbility:set_SlotID (int) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/Items/ItemAbility.cs:30)

Do I stop ability in correct manner? Why I get this warning? The character doesn't have any items, nor uses any <ItemAbilities> at the moment.
 
It looks like you are calling TryStartAbility instead of TryStopAbility. Is that intentional?

Besides that, what is the call stack of the error? I'm confused why you are setting the slot ID - TryStartAbility does not set the slot.
 
Sorry, a typo. I actually do invoke TryStopAbility. My last input is:
void EndPerform() {
characterLocomotion.TryStopAbility(targetSpellAbility); <----- here refers the warning
Spellcaster.ReleaseEvent.Release -= EndPerform;
}
It is invoked from a custom class defined as:
public class TargetSpell : Ability {...}

Then the stack goes:
Opsive.UltimateCharacterController.Character.Abilities.Items.ItemAbility:set_SlotID (int) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/Items/ItemAbility.cs:30)
Opsive.Shared.StateSystem.Preset/GenericDelegate`1<int>:ApplyValue () (at Assets/Opsive/Shared/Runtime/StateSystem/Preset.cs:270)
Opsive.Shared.StateSystem.DefaultPreset:ApplyValues (Opsive.Shared.StateSystem.Preset/BaseDelegate[]) (at Assets/Opsive/Shared/Runtime/StateSystem/DefaultPreset.cs:56)
Opsive.Shared.StateSystem.State:ApplyValues (Opsive.Shared.StateSystem.Preset/BaseDelegate[]) (at Assets/Opsive/Shared/Runtime/StateSystem/State.cs:164)
Opsive.Shared.StateSystem.StateManager:CombineStates (Opsive.Shared.StateSystem.State,bool,Opsive.Shared.StateSystem.State[]) (at Assets/Opsive/Shared/Runtime/StateSystem/StateManager.cs:389)
Opsive.Shared.StateSystem.StateManager:ActivateStateInternal (Opsive.Shared.StateSystem.State,bool,Opsive.Shared.StateSystem.State[]) (at Assets/Opsive/Shared/Runtime/StateSystem/StateManager.cs:368)
Opsive.Shared.StateSystem.StateManager:SetStateInternal (UnityEngine.GameObject,string,bool) (at Assets/Opsive/Shared/Runtime/StateSystem/StateManager.cs:311)
Opsive.Shared.StateSystem.StateManager:SetState (UnityEngine.GameObject,string,bool) (at Assets/Opsive/Shared/Runtime/StateSystem/StateManager.cs:257)
Opsive.UltimateCharacterController.Character.Abilities.Ability:SetState (bool) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/Ability.cs:577)
Opsive.UltimateCharacterController.Character.Abilities.Ability:AbilityStopped (bool) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/Ability.cs:789)
Opsive.UltimateCharacterController.Character.Abilities.Ability:StopAbility (bool,bool) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/Ability.cs:731)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion:TryStopAbility (Opsive.UltimateCharacterController.Character.Abilities.Ability,bool) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:1105)


I tried removing all default item abilities, leaving Equip/Unequip only and setting that to manual invoke. But that did not help
 
Did you override the SlotID in your custom ability? I'm not sure why it's just this ability that is causing problems. With that said, you can prevent the DefaultPreset from storing the value by adding the following to the top of the SlotID property within ItemAbility.cs:

Code:
[Shared.Utility.NonSerialized]
public virtual int SlotID

I'll add the same for the next update.
 
Back
Top