pretty simple… I can see it attached to the actor from the editor detail panel, and I can see the correct component transform and that my widget class is set in the interface, and the draw size is near the size of my actors width.
Here is the code:
AActorTest::AActorTest(const class FObjectInitializer& PCIP)
: Super(PCIP)
{
this->bReplicates = true;
this->bAlwaysRelevant = true;
scene = PCIP.CreateDefaultSubobject<USceneComponent>(this, TEXT("SceneComp"));
if (scene)
{
RootComponent = scene;
}
FStringClassReference MyWidgetClassRef(TEXT("/Game/Blueprints/UI/Debug/DebugCoords.DebugCoords_C"));
UWorld* world = GetWorld();
if (world) {
APlayerController* pc = world->GetFirstPlayerController();
if (pc && pc->IsLocalController())
{
if (UClass* MyWidgetClass = MyWidgetClassRef.TryLoadClass<UUserWidget>())
{
// Create the widget and store it.
//DebugCoordsWidget = CreateWidget<UUserWidget>(pc, MyWidgetClass);
widgetComponent = NewObject<UWidgetComponent>(this, TEXT("DebugCoords"));
//if (!widgetComponent)
//{
// ERROR("Could Not Create Widget Component!");
//}
widgetComponent->RegisterComponent();
widgetComponent->AttachTo(scene);
widgetComponent->SetWidgetSpace(EWidgetSpace::World);
//widgetComponent->SetOwnerPlayer(pc->GetLocalPlayer());
widgetComponent->SetWidgetClass(MyWidgetClass);
widgetComponent->SetWorldRotation(FRotator(90, 0, 0));
widgetComponent->SetWorldLocation(FVector(0, 0, 200));
widgetComponent->SetMaxInteractionDistance(1.0f);
}
}
}
}