hi . iam facing problem almost for one month and i couldent solve it . i need superman or even homelander to help me. i give up…
its about slate that fallow actor using UGameplayStatics::ProjectWorldToScreen. its work fine with widget but when it comes to slate the location got shifted and you feel the slate scale are more smaller .i try to apply aspect ratio to slate position but didnt work.
slate and actor code is basic . here is the codes
actor header code :
class UBoxComponent* MyBoxComponent;
UPROPERTY(Category="CustomActors",EditAnywhere,BlueprintReadWrite)
UUserWidget* GetWidgetSample;
TSharedPtr<class SMyCompoundWidget> MySlate;
actor body code:
void AMyActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if (GetWidgetSample && MySlate) {
FVector3d GetActorLocation = this->GetActorLocation();
FVector2d GetPosition;
if (UGameplayStatics::ProjectWorldToScreen(GetWorld()->GetFirstPlayerController(), GetActorLocation, GetPosition)) {
GetWidgetSample->SetPositionInViewport(GetPosition);
MySlate->SetRenderTransform(FSlateRenderTransform(GetPosition));
}
}
}
slate code:
ChildSlot
[
SNew(SBorder)
.BorderBackgroundColor(FSlateColor(FLinearColor::Red))
[
SNew(SVerticalBox)
+ SVerticalBox::Slot()[
SNew(STextBlock).Text(FText::FromString(TEXT("From Slate")))
]
]
];
i will appreciate any help for this