Download

Someone know of a way to make a world generator made out of blocks but not only?

There is this way:

But then I can only use cubes as the mesh, and then for example if I want to add bushes to the terrain, I cant.

I know there is the way with Instanced Static Meshes but I cant figure out how to not cause a lag once a chunk is “being loaded”… http://prntscr.com/dsao77

I feel like I will waste my time if I will continue doing that in the first way that I showed, there is gotta be a way…

Did you see https://www.youtube.com/watch?v=mI7eYXMJ5eI ? It shows how the designers made the Turn-Based Strategy Game (you can get the project in the learn tab in the launcher). They used events - when one part of generation ended, the event fired, triggering the next one.

Even if I have only 1 chunk to load it will freeze the game for some seconds…

You might consider posting the code directly in the thread instead of link to a screenshot.

Your Algorithm could be doing a lot of work since its O(n^3), the number of iterations being dependent on chunkLineElements.

If its freezing up your frame, you might consider moving the work out of the construction / begin play. Do small amounts of work each frame until its done, then show the completed object.

I tried doing it with event tick so not everything is done together but it’s if I wonna totally remove this freeze lag I will have to make it very slow…


	UInstancedStaticMeshComponent *PrimalItem_Grass_BP = NewObject<UInstancedStaticMeshComponent>(this);
	PrimalItem_Grass_BP->RegisterComponent();
	PrimalItem_Grass_BP->SetStaticMesh(StaticMeshes[0]);
	PrimalItem_Grass_BP->SetFlags(RF_Transactional);
	this->AddInstanceComponent(PrimalItem_Grass_BP);

	for (int32 x = 0; x < chunkLineElements; x++) {
		for (int32 y = 0; y < chunkLineElements; y++) {
			for (int32 z = 0; z < chunkZElements; z++) {
				int32 Index = x + (chunkLineElements * y) + (chunkLineElementsP2 * z);
				FVector IndexVector = FVector(x * voxelSize, y * 10 * chunkLineElements , z * chunkLineElementsP2);
				//int32 MeshIndex = chunkFields[Index];

				PrimalItem_Grass_BP->AddInstance(FTransform(IndexVector));
			}
		}
	}
}