I want to add all DoorKey actors that have the tag ConeKEY to an array, in order to be able to get the number of keys using the Num() function. However, i can’t seem to be able to add the items to the array.
The code in ACpp_DoorKey.h:
UPROPERTY()
TArray<ACpp_DoorKey*> DoorKeys;
And the code in ACpp_DoorKey.cpp:
void ACpp_DoorKey::BeginPlay()
{
Super::BeginPlay();
if (GetWorld())
{
for (TActorIterator<ACpp_DoorKey> Itr(GetWorld()); Itr; ++Itr)
{
if (Itr->ActorHasTag("ConeKey"))
{
UE_LOG(LogTemp, Warning, TEXT("Name: %s"), *Itr->GetName())
ACpp_DoorKey* DoorKey = Cast<ACpp_DoorKey*>(Itr);
DoorKeys.Add(DoorKey);
}
}
}
In the attached image you can see the error.
Any help would be appreciated. Thank you.