I can't create variable of UObject in my AActor class

Hello UE community :smiley:

I’m new in UE c++ development and I wan’t to do a very simple thing :
Create an Actor with variables of UObject class I’ve created.

So I starts to generate an Actor class and an UObject class. Added the include “MyObject.h” in my actor class, everything’s okay but I can’t create variable of my UObject. The problem isn’t the NewObject() function but the problem is MyObject class doesn’t exists. VS say me this err and the UE compilation say the same.

I’m searching for hours a solution in forums, in my own ways, compile, delete cache files (.vs, Binaries, Intermediate, .sln file), close all, check updates (UE5 + VS 2022) but no way…

Thanks :slight_smile: And sorry for bad english :sweat_smile:

initialize in cpp file BeginPlay function like:

theObject = NewObject<UMyObject>();

Then if you want to use in the BeginPlay of the Child Blueprint class just add a delay before because BeginPlay of Blueprints runs before C++ class

1 Like