Can't display widgets in full c++ (but it works in derived BP from the same class)

Hello,

I manage to add a WidgetComponent to an Actor in a blueprint to display a nameplate.
I’m trying to do the same in full C ++ with this code (in my vehicle APawn constructor):

TargetWidget = CreateDefaultSubobject<UWidgetComponent>("Widget");

static ConstructorHelpers::FClassFinder<UUserWidget> hudWidgetObj(TEXT("/Game/UI/UI_Nameplate"));

if (hudWidgetObj.Succeeded())
{
TargetWidget->SetWidgetClass(hudWidgetObj.Class);
TargetWidget->SetWidgetSpace(EWidgetSpace::Screen);
TargetWidget->SetRelativeLocation(FVector(0.0f, 0.0f, 0.0f));
TargetWidget->SetDrawSize(FVector2D(500.0f, 700.0f));
TargetWidget->SetVisibility(true);
TargetWidget->AttachToComponent(CollisionComponent, FAttachmentTransformRules::KeepRelativeTransform);
}
else 
{
	GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, "UI Not Found");
}

When I launch my game in editor, the nameplate is not displayed on my c++ actor in the scene.

But if i create a Blueprint deriving from my c ++ class (without modifying my c ++ code and without modifying the blueprint), the actor using this blueprint displays the nameplate (the full C++ actor in the same level not).

Why ? How can i fix the problem in C++ ?

Note: What is the difference between answers.unrealengine.com and forums.unrealengine.com ?

Hello! I have recently faced smth similiar to it. When you create BP around C++ class, some variables can be set specifically from BP defaults, changing some of C++ variables…