[Sequencer] Dynamically created components marked RF_DuplicateTransient are duplicated by sequencer

Sequencer behaves inconsistently when it records an object with dynamically created components.

UStaticMeshComponents, USkeletalMeshComponents are saved and restored even when RF_DuplicateTransient is set. USceneComponent are not restored even when RF_DuplicateTransient is not set. Because of that it’s impossible to control what dynamically created components should be recorded and which shouldn’t.

Steps to reproduce:

  1. Create 3rd-person example project with code;

  2. Make a way of adding dynamically created components to a ThirdPersonCharacter. Example:

    // .h
    UFUNCTION(BlueprintCallable, Category = Test) void SpawnAddComponent();
    // .cpp
    void ATestCinema2Character::SpawnAddComponent()
    {
      USceneComponent* Comp = NewObject<UStaticMeshComponent>(this, FName(FName("StaticMesh"), GetComponents().Num()), RF_DuplicateTransient);
      Comp->SetupAttachment(GetRootComponent(), NAME_None);
      Comp->RegisterComponent();
    
      Comp = NewObject<USceneComponent>(this, FName(FName("Scene"), GetComponents().Num()), RF_DuplicateTransient);
      Comp->SetupAttachment(GetRootComponent(), NAME_None);
      Comp->RegisterComponent();
    }
    
  3. Start editor, bind new function to a key in level BP:

224379-level-bp.png

  1. Play, press Num 1 several times to make several components:

  1. While playing, go to record sequencer tab, add a new recording and pick a character with dynamically created components;
  2. Press “record” and record a sequence, after that stop recording and play;
  3. Open recorded sequence by double click and select a character created by the sequencer:

  1. We can see that all dynamically created Static Mesh Components were restored while Scene Components were not.

As a result, there’s no consistent way to predict if dynamically created components are going to be restored or not. More importantly, there’s no way to specify different behavior for different components.

Let me know if I could provide more help on the issue, I’ll be glad to help.