[I am following the answers from here][1], but I still couldn’t pass in the TArray into UGameplayStatics::GetAllActorsOfClass().
This is how my code looks like:
#include "GetDebt.h"
#include "../Player/Machine/BaseFrame.h"
#include "FleeingObstacle.h"
AFleeingObstacle::AFleeingObstacle(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer){
//TTransArray<AActor*> Array = this->GetWorld()->PersistentLevel->Actors;
}
void AFleeingObstacle::BeginPlay(){
Super::BeginPlay();
//ERROR CODE
TArray<ABaseFrame*> BaseFrameArray;
UGameplayStatics::GetAllActorsOfClass(this->GetWorld(), ABaseFrame::StaticClass(), BaseFrameArray);
if (BaseFrameArray.Num() > 0){
LOG("Number of ABaseFrame in the TArray: " + FString::FromInt(BaseFrameArray.Num()));
}
}
void AFleeingObstacle::Tick(float Delta){
Super::Tick(Delta);
}
void AFleeingObstacle::Move(){
LOG("MOVING... AT THE SPEED OF SOUND.")
}
and the header file contains the following code:
#pragma once
#include "Obstacle/Obstacle.h"
#include "FleeingObstacle.generated.h"
/**
*
*/
UCLASS()
class GETDEBT_API AFleeingObstacle : public AObstacle
{
GENERATED_BODY()
public:
//PROPERTIES
//FUNCTIONS
AFleeingObstacle(const FObjectInitializer& ObjectInitializer);
void BeginPlay() override;
void Tick(float DeltaSeconds) override;
void Move() override;
};
I am still having this error popping up (Attachment provided):
What am I doing wrong this time? I am so confused.