GetAbility<T>() gets wrong ability

@Justin I have some abilities that share base classes or otherwise can extend another (Glide -> Fly for example). If I then use m_CharacterLocomotion.GetAbility<Glide>() I can end up with a superclass variant (Fly) as opposed to the target subclass which ultimately leads to an error.

This is when I looked more closely into the various GetAbility|ies() overloads and specifically abilityIndex and Index. I thought the former was designed to handle my exact situation (after searching the forum and reading the docs), but after testing the change, it still didn't work. I then looked at the source only to find that Index was instead the identifier being used in the GetAbility<T>(int index) overload body. When I manually set Index however, it fixed my error, but the functionality I was after broke. I then learned that the Index refers to the priority index within the controller.

My questions are:
  1. What is the preferred way to call GetAbility<T>() or any of its overloads when abilities can inherit?
  2. What are the intended uses for the abilityIndex?
  3. If Index is intended to be the priority index within the controller, then why is it public and mutable? I'd otherwise assume the Abilities stack order naturally defines this priority?
  4. Am I missing something obvious or misunderstanding something with respect to abilities?
Thank you for any light you can shed.
 
Using the index is the correct method. I'm not sure where you are seeing an abilityIndex parameter but the index does refer to the ability index within the ability list.
 
Thank you @Justin , I think I understand now.

I'm seeing the abilityIndexparameter here:

1644325417246.png

I was under the impression the abilityIndex was a custom value to set based on the documentation:

Documentation link for below snapshot:

1644325638113.png

Documentation link for below snapshot:

1644325924135.png

So does 101 mean there are 102 abilities where the 101th is the highest in the ability stack? It's hard to imagine there are 1000 abilities in the second example. Any more context you can add to the previous four question is helpful to me and likely anyone else who searches the forum.
 
Ah, that Ability Index parameter is independent of the index within the ability list. That ability index can be an arbitrary number and is just for the animator.
 
Top