For my project I need to be able to save multiple screenshots in a loop in C++ code from a rendered viewpoint.
I wrote the code that’s suppose to rotate the view each iteration by few degrees and saves screen shot with a
FScreenshotRequest::RequestScreenshot method, however after the loop is done I found only one screenshot from the last iteration is saved to the disk. This is my code:
PlayerControllerRef = Cast<APlayerController>(GetController());
for (int32 Yaw = 0; Yaw < 180; Yaw += 5)
{
FString fileName("C:/screenshots");
fileName.Append(FString::FromInt(Yaw));
fileName.Append(FString(".png"));
UE_LOG(LogTemp, Warning, TEXT("%i"), Yaw);
PlayerControllerRef -> GetPawn() -> SetActorRotation(FRotator(0.f, float(Yaw), 0.f));
FScreenshotRequest::RequestScreenshot(fileName, false, false);
}
The Log shows warnings from all iterations. I call this code on BeginPlay of a pawn player.
Can this somehow be fixed so I can save all screenshots that I need, or maybe there is some other function to do this?