I am working with unreal c++. I am trying to add a box of instanced static mashes. but…
- User
I am working with unreal c++. I am trying to add a box of instanced static mashes. but this code snipet only adds them in the y-axis but not in x can you help? preview_building->mesh->ClearInstances(); FTransform t; int dx = 0; int dy = 0; float gridSize = gm->grid_size; for (int x = minX; dx * gridSize < maxX; x++) { dx = x - minX; for (int y = minY; dy * gridSize < maxY; y++) { dy = y - minY; //@TODO calculate/get Z UE_LOG(LogTemp, Warning, TEXT("adding instance at = (%i, %i)"), x, y); t.SetLocation(FVector(gridSize * dx, gridSize * dy, 0)); preview_building->mesh->AddInstance(t); } }
- Assistant
It seems like the issue with your code is related to the conditions in your for-loops. These conditions might be incorrect or not being updated as expected. Moreover, the indexes
dxanddyshould be calculated directly inside your loop. Here's the revised version of your code:cpp