This is a simple method to take screenshots in-game using Unreal Engine 4.23.
Execute this code somewhere in your project and it will generate a PNG screenshot at the same resolution your game is currently rendering at.
// Generate a filename based on the current date const FDateTime Now = FDateTime::Now(); // store screenshot in Project directory next to main UProject/EXE based on the build type #if WITH_EDITOR const FString ImageDirectory = FString::Printf(TEXT("%s/%s"), *FPaths::ProjectDir(), TEXT("Screenshots")); #else const FString ImageDirectory = FString::Printf(TEXT("%s/../%s"), *FPaths::ProjectDir(), TEXT("Screenshots")); #endif const FString ImageFilename = FString::Printf(TEXT("%s/Screenshot_%d%02d%02d_%02d%02d%02d_%03d.png"), *ImageDirectory, Now.GetYear(), Now.GetMonth(), Now.GetDay(), Now.GetHour(), Now.GetMinute(), Now.GetSecond(), Now.GetMillisecond()); FScreenshotRequest::RequestScreenshot(ImageFilename, false, false);
As a bonus, this screenshot will also appear in a convenient "Screenshots" folder in your project, rather than in the Saved/ directory - making this a little more usable for development and players.
This is better than using a manual capture component because this will go through the same render path as your main game, so will pick up any post-processing effects etc.