Download

Custom Actor somehow break Edtor's Undo functionality

So I have this actor:



#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Components/BillboardComponent.h"
#include "MyActor.generated.h"

UCLASS()
class MYPROJECT3_API AMyActor : public AActor
{
    GENERATED_BODY()
public:

   AMyActor()
   {
      PrimaryActorTick.bCanEverTick = true;

      auto Component = CreateDefaultSubobject<UBillboardComponent>(TEXT("Billboard"));
      RootComponent = Component;
   }

   UFUNCTION(CallInEditor)
   void SpawnAnotherActor()
   {
      auto NewActor = GetWorld()->SpawnActor<AActor>();
      UBillboardComponent* SpawnedComponent = NewObject<UBillboardComponent>(NewActor, TEXT("Billboard"));
      NewActor->SetRootComponent(SpawnedComponent);
      SpawnedComponent->RegisterComponent();
   }
};

I can call SpawnAnotherActor from editor and an “almost” identical actor as my AMyActor is spawned in editor world.

But here is a catch. If I move my newly spawned actor (the one from SpawnAnotherActor) and press ctrl+z to undo the move nothing happens. But if I move my AMyActor then I’m able to undo.
Whats wrong? Is it a bug? Have I missed some steps in SpawnedComponent creation/registration?