Hi.
I have a Skill class:
UCLASS(Blueprintable)
class THESIS_1_API USkill : public UObject
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintNativeEvent)
static void OnPress(class ABaseCharacter* BaseCharacter, class ABasePlayerController* PlayerController);
void OnPress_Implementation(class ABaseCharacter* BaseCharacter, class ABasePlayerController* PlayerController);
UFUNCTION(BlueprintNativeEvent)
static void OnRelease(class ABaseCharacter* BaseCharacter, class ABasePlayerController* PlayerController);
void OnRelease_Implementation(class ABaseCharacter* BaseCharacter, class ABasePlayerController* PlayerController);
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<TSubclassOf<ABaseCharacter>> UsedBy;
};
I’m planning to implement skills (abilities like a fireball for exemaple) as classes that would inherit the Skill class. I have an array of such classes in my BaseCharacter:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Skills)
TArray< TSubclassOf<USkill> > Skills;
And I’m trying to call functions from those skills classes in my BasePlayerController like this (CallSkill0OnPress is and action I’ve bound to a key earlier in the code):
void ABasePlayerController::CallSkill0OnPress()
{
if (ABaseCharacter* BC = Cast<ABaseCharacter, APawn>(GetPawn()))
{
if (BC->Skills[0]!=nullptr)
{
BC->Skills[0]->OnPress(BC, this);
}
}
}
And at this point I get a compiler error
Error C2039 ‘OnPress’: is not a member
of ‘UClass’
Which is strange to me as it looks like I tried to call OnPress from UClass, but up to this point I thought I only had USkill classes in the BC->Skills array.
What am I doing wrong here?
Also: how do I add a class type variable (not an object of a class) to an array like the one I introduced in the BaseCharacter?