The best way to do this is to create a camera, create a spawnable from it, and then get the camera component from the camera and add a possessable binding to it. Here’s an example which is in Engine\Plugins\MovieScene\SequencerScripting\Content\Python\sequencer_examples.py:
def create_level_sequence_with_spawnable_camera(asset_name, package_path = '/Game/'):
sequence = unreal.AssetToolsHelpers.get_asset_tools().create_asset(asset_name, package_path, unreal.LevelSequence, unreal.LevelSequenceFactoryNew())
# Create a cine camera actor
camera_actor = unreal.EditorLevelLibrary().spawn_actor_from_class(unreal.CineCameraActor, unreal.Vector(0,0,0), unreal.Rotator(0,0,0))
# Add a spawnable using that cine camera actor
camera_binding = sequence.add_spawnable_from_instance(camera_actor)
# Add a cine camera component binding using the component of the camera actor
camera_component_binding = sequence.add_possessable(camera_actor.get_cine_camera_component())
camera_component_binding.set_parent(camera_binding)
camera_component_binding.set_display_name('renamed')
# Add a focal length track and default it to 60
focal_length_track = camera_component_binding.add_track(unreal.MovieSceneFloatTrack)
focal_length_track.set_property_name_and_path('CurrentFocalLength', 'CurrentFocalLength')
focal_length_section = focal_length_track.add_section()
focal_length_section.set_start_frame_bounded(0)
focal_length_section.set_end_frame_bounded(0)
for channel in focal_length_section.find_channels_by_type(unreal.MovieSceneScriptingFloatChannel):
channel.set_default(60.0)
# Add a transform track
camera_transform_track = camera_binding.add_track(unreal.MovieScene3DTransformTrack)
populate_track(sequence, camera_transform_track, 1, 5)
return sequence
Is there a way to avoid using a dummy scene actor (i.e. calling spawn_actor_from_class)? I would like to use CameraComponent from CineActor from Camera Animation Sequence. I don’t want to create extra objects (cause it binding id will be invalid once I remove actor from the scene)