Hello,
I spent lot of time trying to do this on my own, but can’t get my head around it.
I went through tutorial to enable GameplayAbility system and stopped on a fragment, where I create parameter for UGameplayAbility:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Abilities)
TSubclassOf<class UGameplayAbility> Ability;
Then tutorial sent me to assign ability:
void AARPGCharacter::BeginPlay()
{
Super::BeginPlay();
if (AbilitySystem)
{
if (HasAuthority() && Ability)
{
AbilitySystem->GiveAbility(FGameplayAbilitySpec(Ability.GetDefaultObject(), 1, 0));
}
AbilitySystem->InitAbilityActorInfo(this, this);
}
}
Now I can assign ability through parameter “Ability” in Blueprint and it’s working well. But I want to assign this value dynamically through code. How can I achieve that? I’m looking for something like (example just to understand my question):
AbilitySystem->GiveAbility("SomeAbilityByBlueprintName", 1, 0);