Why is my object variable set to 'none' by the inheriting blueprint?


I have a small problem with object creation:

I created a C++ class “CustomController” derived from APlayerController and another class “UFueledCraftingStation” that is ultimately derived from UObject.
The player controller has a variable of that UObject class (just for testing purposes) and creates an instance in the constructor:

//  .h
class SURVIVE_API ACustomController : public APlayerController



    UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
    UFueledCraftingStation* Dummy;


// .cpp

    Dummy = CreateDefaultSubobject<UFueledCraftingStation>(TEXT("FooBar"));


From this player controller, a Blueprint class “CustomControllerBP” is derived.
It shows the object variable but it is set to none. I can pull up the nodes but any access fails.

I have been searching around and in some posts it was suggested that the blueprint CDO values just overwrites my variable with basically ‘nullptr’.
However I couldn’t find out if that is really whats going on or how to prevent it.

In other words: What am I doing wrong here?
Any help is appreciated :slight_smile:


Hi Klaus,

I think we solved this last night in our Skype call by adjusting the number of fallen-over sacks of rice in China to a prime. :smiley:

for all the others: We seriously have no idea how, but it suddenly worked with no apparent changes. Only guess I have, is that some old stuff was still cached and bad code being used.

Happy coding :smiley:

Indeed. Now it seems to work. The only thing I remember doing “differently” was once compiling the project with an empty constructor. When I compiled again with the constructor code in place, it suddenly worked. I just have to see if that solves again if the issue should reoccur…
Is there a way to discard all transient and potentially spurious generated code, like completely rebuild the blueprint CDOs to make sure nothing gets overwritten with stale values?
Or is there a special compilation order to observe? After I compile my C++ classes, I also compile my derived blueprint after that. Could this be causing some trouble?


Celebrated a bit too early. I added some more code to my project and now after compiling, the BP shows ‘none’ again for the object variable :frowning:
I just don’t know what is causing this. It seems it works when I compile the project from VS rather than the UE editor. But still I have to comment out all constructor code and compile it with an empty constructor while the editor is closed then open the editor, hit compile from there, then open the blueprint. Compile it. Close the editor. remove the comments from the constructor code. Compile from VS. Open the editor and recompile the blueprint.
Then sometimes it works… until I add more code and compile once again… :frowning:


I recreated a little example and made a short video better describing the issue at hand:

Thanks in advance for anyone having a look at this :slight_smile: