Did you know Unreal doesn't support instanced meshes with non-uniformly scaled parent actors?

I got a bug report that some meshes got broken when using my MeshPack plugin. And as any good developer I was sure I had done something wrong. :sweat_smile: But it turns out that UE break/shears the world transform of a (H)ISM instance if the parent actor/components scale is not uniform. :exploding_head:

Lets say you use PLAs as prefabs and you make a table that is 2x1m in size. Then you stretch the PLA so the table is 4x1m in size. (PLA actor scale is now 2,1,1)

Everything would still look fine since rendering uses it’s own method to get the world transform that accounts for this. But everything else like navmesh, collision, etc would look a bit off, like in the attached image. The effect will be stronger the larger the scale difference is.


If you use PLAs as prefabs you might have encountered this where the collision isn’t quite right. Or other strange issues. But it’s hard to tell since the rendering is always correct.


Here is what you would normally do to resolve the world position of an ISM instance. (Or the blueprint function with the same name)

FTransform MyTransform;
InstancedStaticMeshComponent->GetInstanceTransform(InstanceIndex, MyTransform, true);

If you copied the world transform using this and spawned a new mesh it would look like this.

Notice how sheared transform matches the navmesh in the earlier screenshot. Any collision would also follow the same sheared transform.


Turns out the rendering logic uses one way to get the world transform, but every other part of the engine uses the wrong way.

Having instanced meshes inside an actor/component with a non-uniform scale is not that common. But if you use PLAs as prefabs, any non-uniform stretching of that PLA will cause this.

I thought this bug was really strange, so I wanted to share. Hopefully it can help someone in the future.

In the end I ended up making a custom function for my MeshPack plugin. And since it re-packs PLAs it also means it fixes any broken PLAs :blush:

Here is a quick demo of the bug using a PLA with two cubes. Notice how both navmesh and collision are wrong.