How to get a reference of an Actor created in Blueprint

Hello,
I’m having a lot of stability issues with structures I created in Blueprint, and from what I read, it’s better to handle struct in C++.
I’m really a novice in C++, and I’m trying to create an entry in my struct that is of a class of an actor I created in Blueprint.
Right now I’m using this

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Default")
TSubclassOf<UObject> ActorClass;

I’m trying to replace “UObject” with an actor class that I created in Blueprint, not C++, named for example “BP_Guest”.
I tried “TSubclassOf<BP_Guest> ActorClass;” or even “TSubclassOf<UBP_Guest> ActorClass;” but the compilation fail because it can’t find the class.

What should I do instead? Thank you for your help

Blueprint classes are not native compiled classes, they don’t exist when you compile c++. They are generated dynamically at runtime.

In general, you want to use the closest native parent class. If necessary you might even want to create an intermediate c++ class only for that purpose.
For example make hierarchy like this :

UObject (c++)
  - UGuestBase (c++)
    - BP_Guest_A (bp)
    - BP_Guest_B (bp)
    - BP_Guest_C (bp)

Then use TSubclassOf<UGuestBase>

2 Likes

I see, thank you for your answer.
Is there a workaround for Enum? since I can’t have parent enum obviously, I guess my only option is to recreate them in C++ and replace them everywhere its used in blueprints

Enum should convert almost seamlessly to Byte type (uint8 in c++)

UPROPERTY(BlueprintReadWrite)
uint8 ByteVar;

image

1 Like