"UGameplayStatics::GetAllActorsOfClass" is inaccessible

It hsould work, i dont see it being private… not to mention it pointless making that function private.

But keep in mind that function was made for blueprint use anyway (look Kismet name in path), in C++ generally you should use iterators instead like TActorIterator, which instead of finding all objects and create array that you need to loop thruu anyway, allows to loop thru all object on the go one by one as it finds those and you can process them on the go or do selection, as well as break the loop mid way, making it more efficient and performance freidnly, blueprint does not support iterator so that function was made. Here wiki discribing it, but since wiki is damaged click “View Source”

Hey guys! i’m following a udemy tutorial series and have been doing fairly well so far until I can into this error:

Error (active) E0265 function “UGameplayStatics::GetAllActorsOfClass” (declared at line 83 of “d:\Epic\UE_4.20\Engine\Source\Runtime\Engine\Classes\Kismet\GameplayStatics.h”) is inaccessible FPSGame d:\Game Development\Projects\StealthGame\Source\FPSGame\Private\FPSGameMode.cpp 29

I’m not entirely sure how to fix it despite several tries and many hours of frustration!
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.

#include "FPSGameMode.h"
#include "FPSHUD.h"
#include "FPSCharacter.h"
#include "UObject/ConstructorHelpers.h"
#include "Engine/World.h"
#include "Kismet/GameplayStatics.h"

AFPSGameMode::AFPSGameMode()
{
	// set default pawn class to our Blueprinted character
	static ConstructorHelpers::FClassFinder<APawn> PlayerPawnClassFinder(TEXT("/Game/Blueprints/BP_Player"));
	DefaultPawnClass = PlayerPawnClassFinder.Class;

	// use our custom HUD class
	HUDClass = AFPSHUD::StaticClass();
}

void AFPSGameMode::CompleteMission(APawn* InstigatorPawn)
{
	if (InstigatorPawn)
	{
		InstigatorPawn->DisableInput(nullptr);

		if (SpectatingViewpointClass)
		{
		TArray<AActor*> ReturnedActors;
		UGameplayStatics::GetAllActorsOfClass(this, SpectatingViewpointClass, ReturnedActors);

		//Change viewtarget if any valid actor found
		if (ReturnedActors.Num() > 0)
		{
			AActor* NewViewTarget = ReturnedActors[0];

			APlayerController* PC = Cast<APlayerController>(InstigatorPawn->GetController());
			if (PC)
			{
				PC->SetViewTargetWithBlend(NewViewTarget, 0.5f, EViewTargetBlendFunction::VTBlend_Cubic);

			}
		}
		}
		else
		{
			UE_LOG(LogTemp, Warning, TEXT("SpectatingViewpointClass is nullptr. Please update GameMode class with valid subclass. Cannot change spectating view target."))
		}
	}
	OnMissionCompleted(InstigatorPawn);
}