Why is my native component NULL in derived blueprints?

Using UE 4.25.1, Visual Studio 2019, Windows 10, standard editor install (not self-compiled.)

This may be related to UE-76504

I have a native class, call it AMyPawn.

I have a derived class, call it BP_Pawn.

If I add a new component to AMyPawn, call it NewComp, export it with UPROPERTY(BlueprintReadOnly), re-build and re-load using the “Rebuild” cube icon in the editor, and then use Blueprint to try to read this component in BP_Pawn, BP_Pawn will see it as None.

When debugging in the native class, clearly the NewComp is not None. I can get a reference to NewComp by right-clicking Blueprint background and selecting “Get New Comp.” However, when actually executing instances of this blueprint, I get warnings that this component is NULL.

ALSO, and this may be related, while I see NewComp in the component (inherited) browser in the little scene graph in the blueprint editor, if I try to drag it into the blueprint graph editor directly, I get a tooltip error that the component cannot be referenced, and can’t actually drop it.

I have significant work into the BP_Pawn class, and would like it to pick up the fact that it has this new component. Somehow, the Blueprint believes it’s null, and has “overridden” the actual component from the parent.

Some more clues:

  • the component was created with “Add New C++ Class” in the editor. It has the following class declaration:

    UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
    class TWINSTICKTEMPLATE_API URadarComponent : public USphereComponent
    {
    GENERATED_BODY()

The property itself has the following declaration:

	UPROPERTY(Category = Gameplay, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
class URadarComponent* Radar3Component = nullptr;

The project was initially started as a TwinStickShooterTemplate C++ game.

I generally use hot reloading, but not Live Coding.

I can recover from the error by renaming this component instance variable/property in the header for APawn, re-compiling while the editor is closed, and then re-launching the editor.

When clicking the component in the scene-graph in the blueprint editor, the component doesn’t show any properties in the editor property panel – not even the inherited properties from the USphereComponent that it derives from. This is true even for the recovered component.

The answer is that, first, the component became NULL because of stuck marshaling when adding the component in the native actor using hot reload. This is probably still related to UE-76504 and probably should still be fixed.

However, after I fixed that, I still didn’t see the component properties. This was because the component pointer UPROPERTY() didn’t have VisibleAnywhere, only BlueprintReadOnly.

1 Like