CanStartAbility() is called and returned true but ability is not starting and AbilityStarted() is never called?

ttesjt

New member
Hi all, I am having a weird problem today.

I have an item ability "Hold" and when some condition is met, the item ability will stop itself, and then start a new ability. I have something like this in the "Hold":


public override void Update()
{
base.Update();
if (conditionMet) {
m_CharacterLocomotion.TryStopAbility(this);
BlankTestAbility ability = m_CharacterLocomotion.GetAbility<BlankTestAbility>();
m_CharacterLocomotion.TryStartAbility(ability);
}
}


The CanStartAbility() function of the BlankTestAbility is called and returned true without a problem, but the AbilityStarted() will not be called and ability will not start.

public override bool CanStartAbility()
{
Debug.Log("try Start test ab");
return true;
}

Strange enough. I remember the same code worked when the "Hold" was a regular ability. As far as i can recall, this problem appeared after I changed it to item ability. (I have changed many other things to convert it into an item ability and I am not able to change it back to a normal ability to test becuase that would result huge changes in other abilities. However, the code that starts the BlankTestAbility was never changed.) The priority of BlankTestAbility is high enough to start. actually, the BlankTestAbility is not starting even though no other ability is playing.

So I wonder what situation this might be? When CanStartAbility return true but the ability refuse to start.
 
m_CharacterLocomotion.TryStopAbility(this);
What is this? what is the ability your stopping? and have you adapted it into another ability(looks like maybe)? Also you can add forced = true to the input parameter, like so m_CharacterLocomotion.TryStopAbility(this, true);
 
Thank you for the reply!!

Sorry for the confusion. Let me explain my problem in a simpler way:

So , I am trying to start abilityB using abilityA.
abilityA is an item ability. and abilityA will stop itself and then start abilityB in abilityA's update if some conditions are met.
The abilityB' canStartAbility funciton is get called properly and returns true. However the abilityB will not start. Even if there is no active ability.


The abilityA used to be able to start abilityB using this way when abilityA was defined as a normal ability.

So idk, I am guessing there are some problems with starting another normal ability manually in an item ability?


The "stop itself" part for abilityA works fine. Since it's an item ability, I don't actually need to stop itself. I tried to not stop item abilityA and just directly start abilityB. The same thing happens. canStartAbility() get called and return true, but abilityB is not starting.

This is kind of weird...:cry:
 
A really good way to figure out why abilityB isn't starting is to place a breakpoint within UltimateCharacterLocomotion.TryStartAbility and see where it returns early. My guess though based off of that explanation is that abilityB has a lower priority compared to another active ability. CanStartAbility runs before the priority check so that could be why it is not starting. Another reason may be that a second ability is blocking the ability from starting. In all of those situations though by using breakpoint debugging you'll be able to see where the method returns early.
 
Top