I want a certain functionality for my APSCharacter class, but am not sure how to do it.
APSCharacter is the base class. In game class differentiation will arise from creating blue print instances of APSCharacter and setting giving them different abilities.
I want to be able to:
- select the abilities is the APSCharacter blueprints & have this update fields for that component in BP when i select it
- edit component properties for that specific UAbility subclass.
- call the overridden UAbilitySubclass’s OnUse() function.
My current failed attempt at this: (Excluding implementation for OnUse)
Relevant code from PSCharacter:
declaration of the component
/** AugmentationOne class */
UPROPERTY(EditDefaultsOnly, Category=Abilities)
TSubclassOf<class UAbility> PrimAugComponentClass;
class UAbility* PrimAugComponent;
initialization of PrimAugComponent in the APSCharacter constructor
APSCharacter::APSCharacter(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
// ...
PrimAugComponent = CreateDefaultSubobject<UAbility>(TEXT("PrimAugComponent"));
// ...
}
the calling of OnUse() this is the function I want to call in the subclass implementation
void APSCharacter::OnUsePrimAug()
{
// ...
PrimAugComponent->OnUse();
//...
}
Relevant Code from UAbility:
The function I want to overload
virtual void OnUse();
An example property I want to edit in the APSCharacter blueprint when I select the added UAbility components
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Cooldown)
float CDDuration;
ResevantCode from UAbilitySubclass:
the overriding of the OnUse function by my subclass.
virtual void OnUse() override;
Issues I’m currently having:
- When PrimAugComponent->OnUse(); is
called the subclass’s implementation
is not called. - I can not edit values
for the component & cooldown in the
PSCharacter’s BP instance, or
Projectiles to be used for different
abilities.
So, how should I go about this layout to get the effect I want? Where have I gone wrong?