Getting an ability by name or by a drawer

Cheo

Active member
Hello, I'm often relying on custom scripts to call and enable or disable abilities, and am in need of a convenient method to do so. Is it possible to have a drawer of all abilities at disposal in the inspector to quickly select one and not have to manually create a void for each one of them ? A bit like the drawer in the Start Stop Ability in Behavior Tree. Alternatively, is there a way to get an ability just by its name ? Thanks in advance.
 
The UltimateCharacterLocomotion has a public property Abilities, which returns an array of all abilities of your character. You can also get individual abilities as described here for the Jump ability:
 
Yes, but I know that already, what I'm asking about is a way to select an ability type in the inspector or an event window, just like the Start Stop Use node allows with this code :

C#:
public override void OnStart()
        {
            var target = GetDefaultGameObject(m_TargetGameObject.Value);
            if (target != m_PrevTarget) {
                m_CharacterLocomotion = target.GetCachedComponent<UltimateCharacterLocomotion>();
                // Find the specified ability.
                var abilities = m_CharacterLocomotion.GetAbilities(TaskUtility.GetTypeWithinAssembly(m_AbilityType.Value));
                if (abilities.Length > 1) {
                    // If there are multiple abilities found then the priority index should be used, otherwise set the ability to the first value.
                    if (m_PriorityIndex.Value != -1) {
                        for (int i = 0; i < abilities.Length; ++i) {
                            if (abilities[i].Index == m_PriorityIndex.Value) {
                                m_Ability = abilities[i];
                                break;
                            }
                        }
                    } else {
                        m_Ability = abilities[0];
                    }
                } else if (abilities.Length == 1) {
                    m_Ability = abilities[0];
                }
                m_PrevTarget = target;
            }
        }

Here, you can select an ability type with a dropdown drawer, which will return a string that is used to get all corresponding abilities attached to the character. Is there a way to do that outside of Behavior Designer ?
 
If you want a custom editor, you have to implement it yourself. There are no reusable editor UI components coming with UCC. But as you see in the code, BD does nothing else than getting the abilities from the UltimateCharacterLocomotion.
 
Top