I want to make auto-screencapture program.
This code means that camera capture object images located at (0,0,0) from 0 to 360 degrees(y, z axis).
but when the code run, program shutdown.
what is the problem??
cinema_camera_actor = unreal.EditorLevelLibrary.get_all_level_actors()[7]
screenshot_path = “/test/Saved”
initial_location = unreal.Vector(1000.0, 0.0, 0.0)
initial_rotation = unreal.Rotator(0.0, 0.0, 0.0)
initial_transform = unreal.Transform(initial_location, initial_rotation, unreal.Vector(1.0, 1.0, 1.0))
cinema_camera_actor.set_actor_transform(initial_transform, False, False)
center_location = unreal.Vector(0.0, 0.0, 0.0)
radius = 1000.0
for y_angle in range(0, 360, 5):
for z_angle in range(0, 360, 5):
new_location = unreal.Vector(
initial_location.x + radius * math.cos(math.radians(y_angle)),
initial_location.y + radius * math.sin(math.radians(y_angle)),
initial_location.z
)
look_at_rotation = unreal.MathLibrary.find_look_at_rotation(new_location, center_location)
final_rotation = unreal.Rotator(look_at_rotation.pitch, look_at_rotation.yaw + z_angle, look_at_rotation.roll)
new_transform = unreal.Transform(new_location, final_rotation, unreal.Vector(1.0, 1.0, 1.0))
cinema_camera_actor.set_actor_transform(new_transform, False, False)
screenshot_name = f"Screenshot_y{y_angle}_z{z_angle}.png"
screenshot_full_path = f"{screenshot_path}/{screenshot_name}"
unreal.AutomationLibrary.take_high_res_screenshot(100,100,screenshot_full_path ,mask_enabled = True)
time.sleep(2)
#unreal.SystemLibrary.delay(20.0)
#cinema_camera_actor.set_actor_transform(initial_transform, False, False)
unreal.SystemLibrary.print_string(None, “done.”)