This time i really need help. Documentation of this all is pretty poor and i came up asking here. Well to create continous level i need to implement custom terrain (and terrain is a just a bunch of merged procedural planes) tho i created an actor which creates a procedural mesh and registers it (lets call it Tile) and when i place it into the world everything is fine but when i try to create another actor Terrain, for example, that creates a bunch of Tiles, they don
t apper in world.
I know about UWorld::SpawnActor but its only spawns actors without any changes and it
s not working for me because i need to modify that tiles
ATile *temp = NewObject<ATile>(this, ATile::StaticClass());
temp->SetActorLocation(position);
temp->AttachToActor(this, FAttachmentTransformRules::KeepRelativeTransform);
inside tile
mesh = CreateDefaultSubobject(TEXT(“GeneratedMesh”));
RootComponent = mesh;
TArray<FVector> aVertices;
TArray<int32> aTriangles;
TArray<FVector> aNormals;
TArray<FVector2D> aUV0;
TArray<FColor> aVertexColors;
TArray<FProcMeshTangent> aTangents;
for (int y = 0; y < 32; y++) {
for (int x = 0; x < 32; x++) {
aVertices.Add(
FVector(
x * 100,
y * 100,
0
)
);
if (x < (32 - 1) && y < (32 - 1)) {
aTriangles.Add((x * 32) + y);
aTriangles.Add(((x + 1) * 32) + y + 1);
aTriangles.Add((x * 32) + y + 1);
aTriangles.Add((x * 32) + y);
aTriangles.Add(((x + 1) * 32) + y);
aTriangles.Add(((x + 1) * 32) + y + 1);
aNormals.Add(FVector(x, y, 1));
aTangents.Add(FProcMeshTangent(x, y, 1));
}
aUV0.Add(FVector2D(x / 32, y / 32));
aVertexColors.Add(FLinearColor(0.75, 0.75, 0.75, 1.0).ToFColor(true));
}
}
mesh->CreateMeshSection(1, aVertices, aTriangles, aNormals, aUV0, aVertexColors, aTangents, true);
mesh->RegisterComponent();