[Python] Movie Scene Component Material Track only set to Material Element 0

I am trying to animate the parameters of Materials of an staticMeshActor in LevelSequence.
But what ever I do, I can only assign to the Material Element 0. How do I assign to different Material elements of the StaticMesh_Component, or how do loop to material and assign parameters for each Material Element?? Or if not how do I do that in BluePrint??
Here is my code:

def getactorfromWorld2(labelName,sequencePath,timeStart,timeEnd):
    level = unreal.EditorLevelLibrary()
    actor = level.get_all_level_actors()
    for act in actor:
        if act.get_actor_label() == labelName:
            sequence_asset = unreal.LevelSequence.cast(

            setact = sequence_asset.add_possessable(act)
            setHidden = setact.add_track(track_type=unreal.MovieSceneVisibilityTrack)

            setHiddensection = setHidden.add_section()
            channels2 = setHiddensection.get_channels()
            for channel2 in channels2:
                channel2.add_key( unreal.FrameNumber(timeStart),True,sub_frame=0,time_unit=unreal.SequenceTimeUnit.TICK_RESOLUTION)
                channel2.add_key(unreal.FrameNumber(timeEnd*800), False, sub_frame=0, time_unit=unreal.SequenceTimeUnit.TICK_RESOLUTION)
            setCompAct = sequence_asset.add_possessable(act.root_component)
            animation_track2 = setCompAct.add_track(track_type=unreal.MovieSceneComponentMaterialTrack)
            new_section = animation_track2.add_section()
            new_section.add_scalar_parameter_key("Switch", unreal.FrameNumber(timeStart), 0)
            new_section.add_scalar_parameter_key("Switch", unreal.FrameNumber(timeEnd*800), 1)
            new_section.add_color_parameter_key("color",unreal.FrameNumber(timeStart),unreal.LinearColor(1,0,0,0) )
            new_section.add_color_parameter_key("color",unreal.FrameNumber(timeEnd*800) ,unreal.LinearColor(0, 1, 0, 0)

what if you do this instead?

Hmm… let me test it out.

I tried it and doesn’t work…

  • I ran into the same problem. Have you found a solution now?

For 5.1, we’ve added SetMaterialIndex and GetMaterialIndex for PrimitiveMaterialTrack and ComponentMaterialTrack. So, you’ll have to wait for that or if you’re building your own source, you can grab it from github here:

1 Like

Thank you very much. Your reply is very helpful