Problem with GetOverlappingActors and class filter

Hi all !

I got a problem with GetOverlappingActors and how to use the class filter. What do I have to write ? I try with the class type ( AHumanCharacter ), an object of this class ( AHumanCharacter* Human; ) but nothing work.

Can you help me please ? :slight_smile:

Here my function :

void UHealComponent::Heal(float HealValue)
	AHumanCharacter* HumanCharacter;
	TArray<AActor*> HumansInZone;


	for (auto Human : HumansInZone)



Ok I solved this problem, we need to write this :

void UHealComponent::Heal(float HealValue)
	TArray<AActor*> HumansInZone;

	GetOverlappingActors(HumansInZone, TSubclassOf<AHumanCharacter>());

Although it´s a old Post:

but I get this only to work with:

 GetOverlappingActors(CapsuleOverlappedActors, YOURCLASS::StaticClass());

Hi, I know this post is old, but I have a problem, I manage to follow your steps and so far it works pretty well, I can do the GetOverlappingActors with the filter
My problem starts here (I´m coping Vins V code and names just to give and example of my problem):

for (auto Human : HumansInZone)


Inside the for loop I want to send a Message to Human that is understood by the class AHumanCharacter, but Human is of type AActor* so it doesnt understand the message.
From what I have read I think I should be casting Human to AHumanCharacter, but when I do that then in run time the engine crashes. Maybe I´m casting it wrong???

I´m pretty sure the filter works because i´ve tried using Human.Destroy(); and it works just fine only destroying the actors that correspond to AHumanCharacter

Thanks for the help, excuse my english

Try casting to ACharacter (which is derived from APawn) or APawn class, that should be true, as APawn is derived from AActor and a NavAgentInterface.

Hi, thank you for the response, I spent the next day trying to solve it and it was my bad, I was messing up something else that ended up in a null pointer, thank you for the quick response

Hello, I have a problem.
I am trying to make a flag capture area, something like Battlefield’s flags.

This code works for me :

TArray<AActor*> PlayersIn;
GetOverlappingActors(PlayersIn, TSubclassOf<AActor>());

But I want to filter to get only the players, who are using an ACharacter class…
When writing :

TArray<AActor*> PlayersIn;
GetOverlappingActors(PlayersIn, TSubclassOf<ACharacter>());

I get the following error :

Using Visual Studio 2017 14.16.27023 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023) and Windows 10.0.17763.0 SDK (C:\Program Files (x86)\Windows Kits\10).
Building 4 actions with 8 processes...
  [1/4] FlagObjective.cpp
   C:\UE4_forks\Unreal_Projects\VRFracture\Source\VRFracture\FlagObjective.cpp(51) : error C2664: 'void AActor::GetOverlappingActors(TSet<AActor *,DefaultKeyFuncs<InElementType,false>,FDefaultSetAllocator> &,TSubclassOf<AActor>) const'?: impossible de convertir l'argument 2 de 'TSubclassOf<ACharacter>' en 'TSubclassOf<AActor>'
              InElementType=AActor *
  C:\UE4_forks\Unreal_Projects\VRFracture\Source\VRFracture\FlagObjective.cpp(51): note: Aucun op?rateur de conversion d?finie par l'utilisateur disponible qui puisse effectuer cette conversion, ou l'op?rateur ne peut pas ?tre appel?

“impossible de convertir l’argument 2” means “impossible to convert the 2nd argument” in english :wink:
“note : Aucun opérateur de conversion définie par l’utilisateur disponible qui puisse effectuer cette conversion, ou l’opérateur ne peut pas être appelé?” means “note : There is no conversion operator defined by the user available that could do this conversion, or the operator cannot be called?”.

**EDIT : Problem solved, I simply forgot to add

#include "GameFramework/Character.h"