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);
}