How to set up actor in blueprint

I’ve made class, derived from AActor: KeyAActor. It has this field:

UPROPERTY ( EditAnywhere, BlueprintReadWrite, Category = "Button properties" ) AActor* keys;

But I can not set up keys component in editor.


What have I done wrong?
Thanks!

What are you trying to set this value to? Do you have some AActor’s setup in the editor that you can add here?

I’ve tried to make class, derived from UObject KeyProcessor, that have couple of virtual functions, to override them in blueprint. I’ve tried to make KeyProcessor* keys, an that didn’t work. Then I changed to AActor* because I wanted to check, if my class is worng or something else.

If you want to use a class derived directly from UObject you can’t use AActor, since UObject is a parent of AActor. I think the other problem you are having is that references to actors in the defaults can only be to instances that already exist in the scene. Do you have a scene with actors already? If not, try adding a few and see if you can select those.

From object pointers you can only set objects that are already placed in level in defaults (but i’m not sure) and details tab, you can’t guaranty the code that specific object will exist when object will be spawned (that why i’m not sure with defaults). If you want to select class (C++ class or blueprint, they both classes) that you will spawn for example you need to use UClass* for all classes selection or

TSubclassOf<ClassName>

for limited selection (ClassName is a class of base class of classes that will be listed)

Okay, and can I assign UObject pointers in defaults?

You are my hero! TSubclassOf working!

I don’t think you can. Basically, you have to make sure the object exists before you can assign it. Anything in the defaults has to already be in the level since it will be assigned as soon as your actor is created. In your case, if you don’t want to physically place instances in the level, you probably want to use the construction script or begin play node in your KeyAActor class to create the KeyProcessor items you want, then assign them to the array.