I think I found the problem. I tried calling a custom event in my character class and that worked. So the problem is that I’m not referencing the correct ability correctly.
So I have an array of Abilities in my Character class.
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Ability)
AAbility* AbilityArray[4];
Then I have an AAbility variable that holds the value of the current ability.
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Ability)
AAbility* currentAbility;
Then to call an ability I do this
void AMonsterCharacter::CallAbility(int abilityNum){
currentAbility = AbilityArray[abilityNum];
if (currentAbility)
ChargeAbility();
}
ChargeAbility() then calls currentAbility->ChargeAbility(this); Which is a wrapper in my Ability class for a notification, this->NotifyChargeAbility();
I know ChargeAbility gets called because of an OnScreenDebugMessage, so I’m assuming that the event NotifyChargeAbility is also called. The problem is that my currentAbility pointer isn’t pointing to the right Ability instance.
The way I set up my AbilityArray is in BeginPlay I do this:
void AMonsterCharacter::BeginPlay(){
Super::BeginPlay();
AbilityArray[0] = GWorld->SpawnActor<AAbility>(AAbility::StaticClass());
AbilityArray[1] = GWorld->SpawnActor<AAbility>(AAbility::StaticClass());
}
This works fine, the problem is that I want to make Blueprints based on my Ability class and then put those in my AbilityArray.
The way I’ve done this is in my Character Blueprint, in the BeginPlay event, after calling the super, I have this:
You can ignore the Set BP ones, but the SetAbility ones are where the problem might be.
SetAbility 1 - 4 are functions in my Character class.
void AMonsterCharacter::SetAbility1(AAbility* A){
AbilityArray[0] = A;
AbilityArray[0]->AbilityOwner = this;
}