Search code examples
unreal-engine4unreal-blueprintunreal-engine5

Unreal Engine - Taking screenshots automatically


I have an array of transformation matrices representing camera positions. I want to use these to take many screenshots (10s of thousands).

I want to perform this as follows:

  1. Read transform from array
  2. Place camera where it needs to be
  3. Take screenshot (automatically)
  4. Go to 1.

The blueprint I created is the following: enter image description here

Using this blueprint, unreal engine crashes, which I think is due to the loop that tries to run under 1 frame.

How to take these automatic screenshots properly?

PS: new to UE.


Solution

  • You should use a reasonable delay, enough to save the file, between your calls.

    Do not use a for loop, as it's resulting in a blocking call of too many operations.

    Here is something that should work:

    Blueprint graph

    Call "start" once, then "take next" once. "Take next" is recursive, so after this, you just need to wait for needed time, until all images are made.

    You might also consider using a "file exists" node, to check if the sccreenshot you're about to make already was made, and skip if it was. That way, even if you crash in the middle, you won't need to re-make all screenshots.