When i drag an instance of my actor in the level i get at least 3 duplicates. when i move the actor another duplicate is created. here is the code:
for (int y = 0; y < GridSizeY; y++)
for (int x = 0; x < GridSizeX; x++)
{
TSubclassOf<ABlockBase> classname = ABlockBase::StaticClass();
switch (Grid[y * GridSizeX + x])
{
case EBlockType::Basic:
classname = ABlockBase::StaticClass();
break;
case EBlockType::Wall:
classname = AWallBlock::StaticClass();
break;
case EBlockType::Empty:
classname = AEmptyBlock::StaticClass();
break;
case EBlockType::Start:
classname = AStartBlock::StaticClass();
break;
}
UChildActorComponent* component = NewObject<UChildActorComponent>(this, FName(FString::Printf(TEXT("Test %i"), y * GridSizeX + x)), RF_Transient);
component->SetupAttachment(scenecomponent);
component->SetChildActorClass(classname);
component->CreateChildActor();
component->SetRelativeLocation(FVector(x * GridSize, y * GridSize, .0f));
}
}