UChildActorComponent->SetChildActorClass() Fails To Cast To Custom C++ Actor Class

You are making it more complicated than necessary. Spawning actors at constructor time can be done by overriding OnConstruction(const FTransform & Transform) . Just be sure to call the Super::OnConstruction() at the end of your override. And be sure to mark the array you store your actors in as transient. Yea it is possible to use ChildActorComponents to spawn stuff in at BP constructor time, but I don’t like it because it adds another layer of complexity. Subobjects must be created in the constructor, OnConstruction() is the earliest you can call GetWorld->SpawnActor().

As for spawning a grid of a class you want, I would suggest creating a custom box component over a custom actor.

  1. Create a subclass of UBoxComponent for your grid cells.
  2. Create a subclass of AActor, that will spawn your grid.
  3. Override the onconstructor event.
  4. MyBoxComp * Cell = NewObject<USpaceBox(this,MyBoxComp::StaticClass(),FinalName); Use AppendInt on FString to give the components you spawn unique names. (New Object can’t be called in the actual constructor, must be called in OnConstruction() )
    5.Cell->RegisterComponent(); Cell->AttachToComponent(RootComponent,Rules); Cell->SetRelativeLocation(Location);
  5. Probably want bindings for OnComponentBeginOverlap,OnComponentEndOverlap. Use addUniqueDynamic.