I feel like im going insane.
I have a custom character (ASkeletonEnemy) which derives from another class, AAIEnemy, which in turn derives from ACharacter.
AAIEnemy and ASkeletonEnemy share the same controller that contains a reference to certain TargetPoints in the map. To find these, when the Character gets possessed, it calls the following function:
.cpp
void AEnemyController::OnPossess(APawn* PossessedPawn)
{
Super::OnPossess(PossessedPawn);
AAIEnemy* Enemy = Cast<AAIEnemy>(PossessedPawn);
PossessedPawnRef = PossessedPawn;
if (Enemy)
{
UGameplayStatics::GetAllActorsOfClass(GetWorld(), AEnemyTargetPoint::StaticClass(), PatrolPoints);
GEngine->AddOnScreenDebugMessage(-1, 7.f, FColor::Green, TEXT("Should have found the TPs"));
if(PatrolPoints.Num() == 0) GEngine->AddOnScreenDebugMessage(-1, 7.f, FColor::Green, TEXT("Failed to find "));
if (Enemy->Tree->BlackboardAsset)
{
BlackboardComp->InitializeBlackboard(*(Enemy->Tree->BlackboardAsset));
}
BehaviorTreeComp->StartTree(*Enemy->Tree);
}
}
However, when i go to read the array that the references to the TPs should have been allocated to, i realize (after several crashes), that the TArray<> was empty.
The real problem comes from the fact that when i place AAIEnemy in the world, it works perfectly. But, when i place ASkeletonEnemy with the exact same configuration, it magically doesnt find the target points anymore.
I’ve been stuck on this for 3 hours and im losing my mind.
If you need additional context, please say so and i will happily provide.
Thanks