我们目前的做法使用WidgetComponent组件并设置Screen渲染模式,就会出现如上图的问题。我们希望头顶信息不透过来,目前没有找到方法。
如果需要类似真实在3D场景中的物体一样的遮挡,你可以把WidgetComponent设置成World,并自己计算和相机的距离以及朝向来动态调整大小和朝向。
如果需要类似角色不被渲染到,头上的字就整个不渲染,否则就整个渲染的话,你可以重载WidgetComponent,调整TickComponent函数成这样:
void UScreenOccludableWidgetComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
#if !UE_SERVER
if (!IsRunningDedicatedServer())
{
const float RenderTimeThreshold = .05;
auto ParentComp = Cast<UPrimitiveComponent>(GetAttachParent());
if (ParentComp)
{
bool NewVisibility = GetWorld()->TimeSince(ParentComp->LastRenderTime) <= RenderTimeThreshold;
SetVisibility(NewVisibility);
}
}
#endif
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
}
您好,我是新手,请问您是如何实现将TextRenderComponent绑定在人物头顶的呢?并可以显示中文?我用的UE4.18.1+VS2017。