Hello,
I am trying to scale my 3D objects, however when I scale them in code, they always move along an axis and changes its original position.
How can I simply resize (scale) my object while keeping it in its original location?
I am trying to create a 3D map that is tiled with different tile sizes. The end result is my tiles are displaced when scaling.
Also, it shouldn’t be my code?.. The unscaled squares are exactly where they should be.
Quick demonstration of the problem:
FTransform InstanceTransform;
for (int x = 1; x <= 10; x++) {
UInstancedStaticMeshComponent* BlockCopy;
BlockCopy = NewObject<UInstancedStaticMeshComponent>(BlockInstance);
FVector SpawnLocation(x*100, 1, 0.f);
InstanceTransform.SetLocation(SpawnLocation);
BlockCopy->AddInstance(InstanceTransform);
if (x > 5 && x < 8) {
BlockCopy->SetWorldScale3D(FVector(2, 2.f, 1.f));
}
else if (x >= 8) {
BlockCopy->SetWorldScale3D(FVector(1, 4.f, 1.f));
}
BlockCopy->SetStaticMesh(BlockMesh.Object);
}
I expected this to create a straight solid line along the x-axis, but at the scaling points it breaks up. I have been stuck on this for awhile. Here’s an example of intended result:
surely someone knows how to solve this?