# Trying to make automatic, sequential screenshots using CameraActor

**URL:** <https://forums.unrealengine.com/t/trying-to-make-automatic-sequential-screenshots-using-cameraactor/2316767>\
**Category:** Programming & Scripting\
**Tags:** Python, unreal-engine, question\
**Created:** [February 4, 2025, 1:26am UTC](https://forums.unrealengine.com/t/trying-to-make-automatic-sequential-screenshots-using-cameraactor/2316767 "2025-02-04T01:26:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sweet\_kitty79](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sweet\_kitty79](https://forums.unrealengine.com/u/Sweet_kitty79)\
**Post date:** [February 4, 2025, 1:26am UTC](https://forums.unrealengine.com/t/trying-to-make-automatic-sequential-screenshots-using-cameraactor/2316767/1 "2025-02-04T01:26:47Z")

</div>

Hi. I’m trying to make some screenshots using CameraActor and Python code. Everything is running fine, without any error but only last screenshot saves. Any ideas?  
This is code:

```auto
import unreal

# Define camera settings
camera_location = unreal.Vector(100, -100, 150) # (X, Y, Z) in cm

# Spawn CameraActor in the scene
world = unreal.get_editor_subsystem(unreal.UnrealEditorSubsystem).get_game_world()
camera = unreal.get_editor_subsystem(unreal.EditorActorSubsystem).spawn_actor_from_class(
    unreal.CameraActor, camera_location
)

# Ensure the camera is selected
unreal.get_editor_subsystem(unreal.EditorActorSubsystem).set_selected_level_actors([camera])

# Get screenshot directory
screenshot_dir = unreal.SystemLibrary.get_project_directory() + "Screenshots/"
i=0
# Iterate through rotations and capture images
for rotation in range(0, 361,50):
    # Set camera rotation
    camera.teleport(camera_location,unreal.Rotator(0,rotation,0))

    # Define screenshot name
    screenshot_path = f"{screenshot_dir}Room_Wall_{i+1}.png"
    # Take a high-resolution screenshot
    unreal.AutomationLibrary.take_high_res_screenshot(1920, 1080, screenshot_path, camera)

    # Print status
    unreal.log(f"Screenshot {i+1} saved at: {screenshot_path}")
    i+=1

```

And this is log from UE:

```auto
LogActorFactory: Actor Factory attempting to spawn Class /Script/Engine.CameraActor
LogActorFactory: Actor Factory attempting to spawn Class /Script/Engine.CameraActor
LogActorFactory: Actor Factory spawned Class /Script/Engine.CameraActor as actor: CameraActor /Game/model.model:PersistentLevel.CameraActor_0
LogActorFactory: Actor Factory spawned Class /Script/Engine.CameraActor as actor: CameraActor /Game/model.model:PersistentLevel.CameraActor_0
LogPython: Screenshot 1 saved at: C:/UE_PROJEKTY/model_pokoj/Screenshots/Room_Wall_1.png
LogPython: Screenshot 2 saved at: C:/UE_PROJEKTY/model_pokoj/Screenshots/Room_Wall_2.png
LogPython: Screenshot 3 saved at: C:/UE_PROJEKTY/model_pokoj/Screenshots/Room_Wall_3.png
LogPython: Screenshot 4 saved at: C:/UE_PROJEKTY/model_pokoj/Screenshots/Room_Wall_4.png
LogPython: Screenshot 5 saved at: C:/UE_PROJEKTY/model_pokoj/Screenshots/Room_Wall_5.png
LogPython: Screenshot 6 saved at: C:/UE_PROJEKTY/model_pokoj/Screenshots/Room_Wall_6.png
LogPython: Screenshot 7 saved at: C:/UE_PROJEKTY/model_pokoj/Screenshots/Room_Wall_7.png
LogPython: Screenshot 8 saved at: C:/UE_PROJEKTY/model_pokoj/Screenshots/Room_Wall_8.png
LogCore: Display: Tracing Screenshot "Room_Wall_8" taken with size: 1920 x 1080

```

---

<div class="post-metadata">

**Author:** ![colton\_jhuapl](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@colton\_jhuapl](https://forums.unrealengine.com/u/colton_jhuapl)\
**Post date:** [April 2, 2025, 6:08pm UTC](https://forums.unrealengine.com/t/trying-to-make-automatic-sequential-screenshots-using-cameraactor/2316767/3 "2025-04-02T18:08:03Z")

</div>

This thread mostly addresses the issue: [Python API/highrescreenshot - #4 by mamoniem](https://forums.unrealengine.com/t/python-api-highrescreenshot/132783/4)

I have found that the solution (using register\_slate\_pre\_tick\_callback) only works when being run from the Editor originally (and not using python’s subprocess package). Once I implemented this solution, I noticed that you still have to code a wait period into the script to let all the screenshots get processed. In my quest to have a dynamic wait period that is only as long as necessary, I employed register\_slate\_post\_tick\_callback in a similar way to register a loop for waiting, but so far it seems I don’t even need to encode any waiting, and seemingly the mere existence of the post tick callback makes the script wait for the previous pretick to finish.
