C++; Widget not getting visible when calling parent's SetActorHiddenInGame(false)

UE4.19

In the constructor of my class (let’s call it “Menu”), derived from Actor, I create the following widget:

menuWidget = CreateDefaultSubobject(TEXT(“Widget”));

menuWidget->AttachTo(RootComponent);

menuWidget->RegisterComponent();

In the editor, in the BP derived from this class (lets call it “BP_widget”), I set the class of the widget.
For testing purposes, I also add a cube and a another widget (lets call it “secondWidget”) as children of the widget created by code.
The “menuWidget” and the “secondWidget” have the same rotation and everything else.
All components (the “menuWidget”, the cube and the “secondWidget”) are visible in the editor.
If I add the “BP_widget” manually to the level using the editor, they are all visible correctly during the gameplay.

At BeginPlay in the “BP_pawn” I initialize an object of the type “BP_widget” (let’s call it “widgetObj” and call “widgetObj->SetActorHiddenInGame(true)”.

On trigger button event in “BP_pawn” I call “widgetObj->SetActorHiddenInGame(false)” (calling tested both in code and in BP).
This sets all (cube and “secondWidget”) components except the “menuWidget” to visible.

I found that after removing the line “menuWidget->RegisterComponent();” from my code from above, the “menuWidget” will be set to visible correctly and all the components will be visible.

Hello,

We’ve recently made a switch to a new bug reporting method using a more structured form. Please visit the link below for more details and report the issue using the new Bug Submission Form. Feel free to continue to use this thread for community discussion around the issue.

https://forums.unrealengine.com/unreal-engine/announcements-and-releases/1410408-unreal-engine-bug-submission-form

Thanks