How to use SphereOverlapActors in C++

Hi everyone,

I know that my question seems silly. But I’m stucked with that for hours now.

I just want to know how we can use UKismetFunctionLibrary::SphereOverlapActor();

Here is my code :

  • First, i’m initiating my filters array.

     m_objectTypes.Add(UEngineTypes::ConvertToObjectType(ECollisionChannel::ECC_WorldDynamic));
     m_objectTypes.Add(UEngineTypes::ConvertToObjectType(ECollisionChannel::ECC_PhysicsBody));
    
     m_actorsToIgnore.Add(GetOwner());
    
     m_pWorld = GetWorld();
    
  • Then I just use the function in tick :

      TArray<AActor*> overlappedActors;
     		UKismetSystemLibrary::SphereOverlapActors(m_pWorld,
     			GetComponentLocation(),
     			m_radius,
     			m_objectTypes,
     			nullptr,
     			m_actorsToIgnore,
     			overlappedActors);
    

But my array of actors is always empty.

I’ve already checked if i was in the good positionn with a radius big enough.

It’s truly the classical problem :“If don"t know it, you can’t use it”

Bests,

Alexandre

I have exact same problem and haven’t had any progress in over 20 hours.
It’s really frustrating

I faced the same problem.
You should import the library first

#include “Classes/Kismet/KismetSystemLibrary.h”

and the use it:

UKismetSystemLibrary::IsValidClass(SomeClass)

For anyone looking for a solution :

  1. Make sure that your actor has either a StaticMesh with a Collider
  2. or your actor has a Collision Component
  3. The Collision preset on your colliders matches the one you have used in your code, the one that is like ECC_**.