Announcement

Collapse
No announcement yet.

Is it possible to import focal length animation onto a camera in Sequencer?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Is it possible to import focal length animation onto a camera in Sequencer?

    Does anyone know if it's possible to get the focal length to import from an fbx onto a camera that exists(as a spawnable) in sequencer?

    I've never written python code before but I'm attempting to make a UI for importing animation, and building sequences. I've got pretty much everything working, except I can't get focal length animation to import onto a camera in sequencer. I can get translation animation to import, but not focal length. I'm guessing it has something to do with the fact that the focal length attribute is on the CameraComponent, or maybe unreal.SequencerTools.import_fbx() doesn't read focal length from the fbx? I dunno...

    Another weird thing is that the 'reduce_keys' property of unreal.MovieSceneUserImportFBXSettings() just gets ignored, whether True or False. All the other properties work, but that one doesn't. If I manually import a camera before running my script, my script will use whatever the property was set at during the manual import. I guess I can live with this, but it's a bit weird.

    Here is the code I am using to import camera animation. Am I doing something incorrectly?:

    Code:
    import unreal
    
    world = unreal.EditorLevelLibrary.get_editor_world()
    sequencer_asset_path = '/Game/Sequences/CameraTest_seq'
    sequence = unreal.load_asset(sequencer_asset_path)
    input_file = 'D:/PretendDirectory/Animation/camera.fbx'
    
    # Set camera's import options
    def import_camera_FBX():
        import_options = unreal.MovieSceneUserImportFBXSettings()
        import_options.set_editor_property('create_cameras', False)
        import_options.set_editor_property('force_front_x_axis', False)
        import_options.set_editor_property('match_by_name_only', False)
        import_options.set_editor_property('reduce_keys', False)
        import_options.set_editor_property('reduce_keys_tolerance', 0.001)
        return import_options
    
    # Find the camera bindings in the sequence
    def camera_bindings():
        bindings = sequence.get_bindings()
        return bindings
    
    # unreal.SequencerTools.import_fbx(world, sequence, bindings, import_fbx_settings, import_filename)
    unreal.SequencerTools.import_fbx(world, sequence, camera_bindings(), import_camera_FBX(), input_file)

    #2
    Ok, I've realised part of my mistake. unreal.SequencerTools.import_fbx() can be used to import animation onto anything, not just cameras, so it probably doesn't read the focal length attribute at all (the create_cameras property threw me off). Must be something else happening when importing by right-clicking a camera in the sequencer.

    Comment


      #3
      I've been asking for a means to import focal length animation since forever, right now there is no way I know of that can make it work. I always resort to manually re-animating the Focal in sequencer.

      Its too bad because sometimes you have complex camera moves in cut scenes and you need to be able to simply import that animation instead of trying to redo it in an approximate way.

      Comment


        #4
        Originally posted by William K View Post
        I've been asking for a means to import focal length animation since forever, right now there is no way I know of that can make it work. I always resort to manually re-animating the Focal in sequencer.

        Its too bad because sometimes you have complex camera moves in cut scenes and you need to be able to simply import that animation instead of trying to redo it in an approximate way.
        Importing camera transform and focal length animation works for me. I usually import animation by right clicking the camera in my sequence and choosing Import (only works on Cine Cameras, not regular cameras). I'm hoping I can do this same import process through python, but can't work out how.

        Comment

        Working...
        X