I’m working with the GameplayAbilities system, and I’m having trouble understanding how the Input handling works for the AbilitySystemComponent.
There is a ‘GameplayAbilitiesSet.h’ class that shows a way to give multiple abilities to the AbilitySystemComponent, which includes an input designation as shown here:
/**
* This is an example input binding enum for GameplayAbilities. Your project may want to create its own.
* The MetaData default bind keys (LMB, RMB, Q, E, etc) are a convenience for designers setting up abilities sets
* or whatever other data you have that gives an ability with a default key binding. Actual key binding is up to DefaultInput.ini
*
* E.g., "Ability1" is the command string that is bound to AbilitySystemComponent::ActivateAbility(1). The Meta data only *suggests*
* that you are binding "Ability1" to LMB by default in your projects DefaultInput.ini.
*/
UENUM(BlueprintType)
namespace EGameplayAbilityInputBinds
{
enum Type
{
Ability1 UMETA(DisplayName = "Ability1 (LMB)"),
Ability2 UMETA(DisplayName = "Ability2 (RMB)"),
Ability3 UMETA(DisplayName = "Ability3 (Q)"),
Ability4 UMETA(DisplayName = "Ability4 (E)"),
Ability5 UMETA(DisplayName = "Ability5 (R)"),
Ability6 UMETA(DisplayName = "Ability6 (Shift)"),
Ability7 UMETA(DisplayName = "Ability7 (Space)"),
Ability8 UMETA(DisplayName = "Ability8 (B)"),
Ability9 UMETA(DisplayName = "Ability9 (T)"),
};
}
/**
* Example struct that pairs a enum input command to a GameplayAbilityClass.6
*/
USTRUCT()
struct FGameplayAbilityBindInfo
{
GENERATED_USTRUCT_BODY()
UPROPERTY(EditAnywhere, Category = BindInfo)
TEnumAsByte<EGameplayAbilityInputBinds::Type> Command;
UPROPERTY(EditAnywhere, Category = BindInfo)
TSubclassOf<UGameplayAbility> GameplayAbilityClass;
};
Its then converted into an int32 here when given to the ability:
AbilitySystemComponent->GiveAbility(FGameplayAbilitySpec(BindInfo.GameplayAbilityClass->GetDefaultObject<UGameplayAbility>(), 1, (int32)BindInfo.Command));
My problem is that I cannot figure out how to link designations from this enum to actual Action Mappings from DefaultInput.ini. Nor can I understand how to properly register the AbilitySystemComponent to an InputComponent. I’ve managed to use GiveAbility to provide an ability blueprint, which is then triggered by TryActivateAbilityUsingClass. I’ve spent today basically trying to figure this input method out, so that I can utilise the Input Pressed/Released commands within GameplayAbility class.
I know this system is still experimental, but any help with this would be hugely appreciated :).