WidgetComponent won't render in world

Hi everyone, I have created a Widget Component using C++ and attached it to a box trigger by creating it’s default sub object in C++ for the Interactive portal I’m doing, the Widget component is supposed to show when ever a player character enters the bounds of the portal, but has shown on the GIF bellow, it is only possible to enable/show the image if I click on any property inside the details panel to redraw the widget…

I followed the answer show in this question: WidgetComponent Not Visible when added via C++ - UI - Unreal Engine Forums, but the problem still persists and it’s not shown.

The idea is to show this dpad image, but for some reason it’s only showing the white screen and only if I cause a manual redraw by changing a property of the details panel.

Screenshot - 873ff6ec7eac72fece38b4eb40dfa0b4 - Gyazo

some of the code I’m using is has follows and the main class that contains the Widget Component is a UActorComponent:

This is the BeginPlay of the Component:
Super::BeginPlay();

	if (InteractiveWidgetComp)
	{
		UUserWidget* InteractiveWidget = InteractiveWidgetComp->GetUserWidgetObject();
		if (InteractiveWidget)
		{
			UImage* ImgInteractive = Cast<UImage>(InteractiveWidget->GetWidgetFromName("ImgButtonToInteract"));

			if (ImgInteractive)
			{
				InteractiveMaterialInstance = ImgInteractive->GetDynamicMaterial();
			}
		}
	}

And this is the code to actually render the Widget when the player enters the Box Trigger:

void UInteractableComponent::BeginNotifyInteractive(AActor* InteractiveActor, FVector BeginPosition, FVector EndPosition, int KeyPositionToEnable)
{
	if (InteractiveActor->IsA(MyPlayerCharacter::StaticClass()))
	{
		MyPlayerCharacter* Player = Cast<MyPlayerCharacter>(InteractiveActor);
		APlayerController* PC = Cast<APlayerController>(Player->GetController());

		FVector RelativeInteractiveLocation = FVector(0, 0, 50);
		FRotator RelativeCameraRotation = Player->GetCameraBoom()->GetComponentRotation() + FRotator(0.0f, 90.0f, 0.0f);

		if (InteractiveMaterialInstance)
		{
			InteractiveMaterialInstance->SetScalarParameterValue("InteractiveButtonToShow", KeyPositionToEnable);
		}

		if (PC)
		{
			InteractiveWidgetComp->SetTwoSided(true);
			InteractiveWidgetComp->SetVisibility(true);
			InteractiveWidgetComp->SetGenerateOverlapEvents(false);
			InteractiveWidgetComp->SetWidgetSpace(EWidgetSpace::World);
			InteractiveWidgetComp->SetDrawSize(FVector2D(50.0f, 50.0f));
			InteractiveWidgetComp->SetOwnerPlayer(PC->GetLocalPlayer());
			InteractiveWidgetComp->SetBlendMode(EWidgetBlendMode::Opaque);
			InteractiveWidgetComp->SetRelativeRotation(RelativeCameraRotation);
			InteractiveWidgetComp->SetRelativeLocation(RelativeInteractiveLocation);
			InteractiveWidgetComp->SetCollisionEnabled(ECollisionEnabled::NoCollision);
			InteractiveWidgetComp->AttachToComponent(Player->GetRootComponent(), FAttachmentTransformRules::KeepRelativeTransform);
		}
	}
}

Update: Hey guys a little update, I have fixed the issue with the D-Pad Image not showing, I had set up the image in the Widget Blueprint has hidden, so it wasn’t rendering correctly since I never changed it to visible in code, that has been fixed, but I can’t still seem to be able to render it unless I go inside the details and update any property of the actor.

So I also added the request redraw, but it didn’t work, it still needs me to manually update anything from the details panel to make it work.

Here are a couple of things that might help pinpoint the problem:

this is the Quickwatch after the request redraw: Screenshot - c94ac5303204e9a876deaf77175dd888 - Gyazo

and this is the thing I think is causing the problem: Screenshot - 8adb03d4477c4df6de3aedd97de9256c - Gyazo

I don’t really understand why it’s registering the component two times, once has if it where a child and another has a component when it should only add it has a component.

Hey guys, so I was able to finally get this to work, and the way I got it, was to initialize it when I start the BeginNotifyInteractive method on the overlap, So I basically did this:

if (!IsWidgetInitialized && InteractiveWidgetComp != nullptr && !InteractiveWidgetComp->IsPendingKill())
	{
		InteractiveWidgetComp->SetWidgetClass(InteractiveUserWidget);

		UUserWidget* InteractiveWidget = InteractiveWidgetComp->GetUserWidgetObject();
		if (InteractiveWidget != nullptr && !InteractiveWidget->IsPendingKill())
		{
			IsWidgetInitialized = true;
			UImage* ImgInteractive = Cast<UImage>(InteractiveWidget->GetWidgetFromName("ImgButtonToInteract"));

			if (ImgInteractive)
			{
				InteractiveMaterialInstance = ImgInteractive->GetDynamicMaterial();
			}
		}
	}

Basically the problem came because I was trying to instantiate the Widget before the Component had begun play, so by doing this only the first time the player enters the trigger, I make sure that the Component has actually Begun play and it will be able to add the widget correctly.

Thank you and hope this helps someone else.