Create Blueprint class and use UGameplayStatics

I need to create a new Blueprint class, by extending UObject. The only thing is that inside a UObject I can’t use functions from UGameplayStatics (e.g. getAllActorsOfClass). In order to use these functions I need to extend other classes such as Actor or ActorComponent, but I don’t want to extend them (I need an object, not an Actor or a Component).

Is there a way to use the UGameplayStatics functions by extending an Object?

Perhaps you could try making a C++ class that has

#include "Kismet/GameplayStatics.h"

Perhaps then if you extend it in BP, you’d be able to use those functions.

Or put any code that requires GetAllActorsOfClass in your GameMode, and populate the UObject when you create it.

The way is not so intuitive.

To know how to do it look at the answer of @VictorRachels to this question and my comment to their answer.

Thanks for the hint, unfortunately it’s not so easy. I found how to do it (look at my answer) and it is just a little bit longer.

Ah, good to see an answer to this.