I want to make a procedural Voxel world and to make it build faster I want to use a ProceduralMesh but I have problems with the collision. Maybe somebody could help me with it.
That is the code made so far
in the .h file:
UPROPERTY(EditAnyWhere)
UProceduralMeshComponent* mesh;
And in the .cpp:
mesh = CreateDefaultSubobject<UProceduralMeshComponent>(TEXT("GeneratedMesh"));
TArray<FVector> vertices;
vertices.Add(FVector(0, 0, 0));
vertices.Add(FVector(0, 100, 0));
vertices.Add(FVector(0, 0, 100));
TArray<int32> Triangles;
Triangles.Add(0);
Triangles.Add(1);
Triangles.Add(2);
TArray<FVector> normals;
normals.Add(FVector(1, 0, 0));
normals.Add(FVector(1, 0, 0));
normals.Add(FVector(1, 0, 0));
TArray<FVector2D> UV0;
UV0.Add(FVector2D(0, 0));
UV0.Add(FVector2D(0, 10));
UV0.Add(FVector2D(10, 10));
TArray<FColor> vertexColors;
vertexColors.Add(FColor(100, 100, 100, 100));
vertexColors.Add(FColor(100, 100, 100, 100));
vertexColors.Add(FColor(100, 100, 100, 100));
TArray<FProcMeshTangent> tangents;
tangents.Add(FProcMeshTangent(1, 1, 1));
tangents.Add(FProcMeshTangent(1, 1, 1));
tangents.Add(FProcMeshTangent(1, 1, 1));
mesh->SetMobility(EComponentMobility::Movable);
mesh->SetSimulatePhysics(true);
mesh->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
SetActorEnableCollision(true);
mesh->CreateMeshSection(1, vertices, Triangles, normals, UV0, vertexColors, tangents, true);
mesh->SetupAttachment(RootComponent);
Thanks For any answers and if someone knows a way how I can learn more about Procedural Meshes I would although be really happy. : )