Hello, I am using a scene capture component 2D to create Icons dynamically, it works fine however, there the scene capture doesn’t update properly. The distance of the scene-capture from the model is calculated so that the model fits the screen. When the function is called it does not render the icon with the proper distance between them. If I call the function again or a previous item required the same distance then the scene-capture renders the right distance.
This is the function to create the icon
//set the model and calculate the distance to fit the icon to the screen
InitialiseModel();
//set the new render target to the model
UTextureRenderTarget2D* NewRenderTarget = UKismetRenderingLibrary::CreateRenderTarget2D(GetWorld(), Width, Height, ETextureRenderTargetFormat::RTF_RGBA16f, FLinearColor(0.0f, 0.0f, 0.0f, 0.0f));
SceneCapture->TextureTarget = NewRenderTarget;
//capture scene
SceneCapture->UpdateContent();
SceneCapture->CaptureScene();
//convert the render target to texture2D
UTexture2D* CachedRenderTexture = CreateTextureFromRenderTarget(NewRenderTarget);
return CachedRenderTexture;
This is the distance setter
void AIconCreator::SetDistance(float Distance)
{
//SpringArm->TargetArmLength = Distance;
SceneCapture->SetRelativeLocation(FVector(Distance * -1.0f, 0.0f, 0.0f), false, nullptr, ETeleportType::TeleportPhysics);
}
This leads me to believe that either the scene-capture is lagging behind or setting the relative location doesn’t happen instantly, I am asking if anyone knows a way around this issue, so I can capture the models with the proper distance.
I have tried using changing the scene-capture and actor tick group to “post update work” and I tried changing the scene-capture “CaptureEveryFrame” to true. Orginally the scene capture was connected to a spring arm and this had the same problem so I thought the spring arm was causing the delay but directly setting the scene-capture location still gives the same problem.