Getting camera transforms of sequence with Python

I’m trying to export the camera transforms (world coordinates) from a rigged camera with Python. (Cine Camera Actor on a Camera Rig Rail)

However, I can’t seem to advance the time to get the whole sequence of frames. The transform seems always to stay the same.

My code is roughly as follows:

for frame in range(total_frames):
  frame_num = unreal.FrameNumber()
  frame_num.value = frame
  frame_time = unreal.FrameTime(frame_num)
  position = unreal.MovieSceneSequencePlaybackParams(frame=frame_time)
  sequence_player.set_playback_position(position)

  # Get the evaluated world transform of the camera actor
  transform = camera_actor.get_actor_transform()

Putting a play/pause after the set_playback_position doesn’t seem to help. Putting a time.sleep() just blocks UE5.

Any ideas what I can do to get the transforms for every frame?

Can you try setting the position type to unreal.MovieScenePositionType.FRAME? So, this line:

position = unreal.MovieSceneSequencePlaybackParams(frame=frame_time)

change it to:

position = unreal.MovieSceneSequencePlaybackParams(frame=frame_time, position_type=unreal.MovieScenePositionType.FRAME)

Also, I’m not entirely sure what your sequence_player is. I would suggest you use the editor functions in unreal.LevelSequenceEditorBlueprintLibrary. If you call unreal.LevelSequenceEditorBlueprintLibrary.set_local_position, it should force an update automatically each frame.