I am trying to fire the “AttackCharacter” custom event off my character but it needs to be the owning character, how would I properly cast to my owning character?
EBTNodeResult::Type UTask_Attack::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
{
UBlackboardComponent* blackboardComp = OwnerComp.GetBlackboardComponent();
bool canSeeEnemy = blackboardComp->GetValueAsBool(canSeeEnemyKey);
AActor* enemyActor = Cast <AActor>(blackboardComp->GetValueAsObject(enemyCharacterKey));
bool isInRange = blackboardComp->GetValueAsBool(isInrangeKey);
if (canSeeEnemy && isInRange)
{
AAIController* AIOwner = OwnerComp.GetAIOwner();
ACharacter* ownerCharacter = Cast<ASHAICharacter>(AIOwner->GetCharacter());
if (ownerCharacter)
{
ownerCharacter->AttackCharacter(enemyCharacterKey);
}
}
return EBTNodeResult::Succeeded;
}