Download

Having a type conversion error with FGameplayAbilitySpec constructor; while I don't get it in a different file [SOLVED]

Hi everyone.

I’m using Gameplay Ability System for my graduation project. I re-wrote the code that has been used in ActionRPG sample to learn the system in detail.

It’s working actually. But the constructor of FGameplayAbilitySpec given me error while it’s working with another classes.

The system given me this error:

GameplayAbilityBase is subclass of GameplayAbility. But for some reason I can’t give as an argument while I could with a different class. I don’t know what is the difference and need your help. :slight_smile:

I know using the exact template as they did in the ActionRPG is not optimal(!) But it was faster and the system support what I want.

Hi Everyone. I’ve found the problem… And you guessed it, it was a missing header file.

What I’ve learned right now is: TSubClassOf variable type requires the class T to be defined. Naturally :smiley:

Sorry for bothering you :slight_smile: Hope this post will help some one to realize earlier.

Here is the missing header file :smiley:
image

For beginners I would like to state that my ItemBase class stores those GameplayAbilities as TSubClassOf Granted Abilities, while FGameplayAbilitySpecs class stores them as TSubClassOf Abilities.

Since the UGameplayAbilityBase is a sub-class of UGameplayAbility is should work without a problem because TSubClassOf is supporting those kinds of type conversions. But for it to be able to convert the type, it needs to know the what class you’re passing to it. Adding the header that stores the definition of the UGameplayAbilityBase class, allows TSubClassOf<> to know and convert the classes. This way those variables can act as if they were defined with the classes that is passed to TSubClassOf<>.

For example:
if everything defined properly.

TSubClassOf GrantedAbilities; Variable is able to act as if it was defined as UGameplayAbilityBase GrantedAbilities.

Did I get it right? Or am I confused? I would like to learn it. :slight_smile: