# UGameplayStatics::GetAllActorsOfClass is inaccessable?

**URL:** <https://forums.unrealengine.com/t/ugameplaystatics-getallactorsofclass-is-inaccessable/434501>\
**Category:** C++\
**Tags:** error, coding, unreal-engine, UE4, CPP, question\
**Created:** [September 26, 2018, 12:34am UTC](https://forums.unrealengine.com/t/ugameplaystatics-getallactorsofclass-is-inaccessable/434501 "2018-09-26T00:34:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_db3a3d69](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_db3a3d69](https://forums.unrealengine.com/u/anonymous_user_db3a3d69)\
**Post date:** [September 26, 2018, 12:34am UTC](https://forums.unrealengine.com/t/ugameplaystatics-getallactorsofclass-is-inaccessable/434501/1 "2018-09-26T00:34:21Z")

</div>

I have been trying to implement multiple different uses of UGameplayStatics but I consistently am met with the error of “UGameplayStatics::GetAllActorsOfClass is inaccessible”. Based on documentation and everyone else, this clearly should not be the case.

I have been trying to use multiple different #include for referencing UGameplayStatics but none of them seem to make a change.

Sample Code:

```
#include "MyAIController.h"
#include "Kismet/GameplayStatics.h"

void AMyAIController::Possess(APawn* Pawn)
{
	Super::Possess(Pawn);

		TArray<AActor*> FoundActors;

		UGameplayStatics::GetAllActorsOfClass(GetWorld(), AAITargetPoint::StaticClass(), FoundActors);

}

```

Am i referencing UGameplayStatics incorrectly or is there a bigger issue i should be looking for?

---

<div class="post-metadata">

**Author:** ![AyanMiru](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ayanmiru/32/1194638_2.png) [@AyanMiru](https://forums.unrealengine.com/u/AyanMiru)\
**Post date:** [September 26, 2018, 3:31am UTC](https://forums.unrealengine.com/t/ugameplaystatics-getallactorsofclass-is-inaccessable/434501/2 "2018-09-26T03:31:41Z")

</div>

I had the same problem. This approach worked for me better:

[A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums](https://wiki.unrealengine.com/Iterators:)_Object_%26\_Actor\_Iterators,\_Optional\_Class\_Scope\_For\_Faster\_Search

```
#include "EngineUtils.h"
#include "Engine/StaticMeshActor.h"

for (TActorIterator<AStaticMeshActor> ActorItr(GetWorld()); ActorItr; ++ActorItr) 
   { 
    	AStaticMeshActor *Mesh = *ActorItr; 
    	UE_LOG(LogTemp, Warning, TEXT("Found Actor: %s"),*Mesh->GetName());
    }
```
