Download

Best way to manually update skeletal mesh vertex positions in UE 4.21

Hi,
I’m attempting to update the vertex positions of a UE 4.21 skeletal mesh character in c++. The idea is that I only update the positions during runtime and not the positions of the actual unreal asset.

I have implemented the following, but it isn’t working:

  1. Created new MyCharacter class derived from ACharacter
  2. Imported an animated skeletal mesh using MyCharacter as it’s blueprint and placed it in a level.
  3. Updated MyCharacter::Tick(float DeltaTime) to look like the following:

Super::Tick(DeltaTime);
auto mesh = this->GetMesh();
if (mesh == nullptr) return;

auto renderData = mesh->GetSkeletalMeshRenderData();
if (renderData == nullptr) return;

if (renderData->LODRenderData.Num() <= 0) return;
if (renderData->LODRenderData[0].GetNumVertices() <= 10) return;
for (auto vertexCount = 0; vertexCount < 10; ++vertexCount)
{
renderData->LODRenderData[0].StaticVertexBuffers.PositionVertexBuffer.VertexPosition(vertexCount) += FVector(500, 500, -1000);
}
mesh->PostEditChange();
mesh->PostLoad();
mesh->MarkRenderStateDirty();

The code above does not update any vertex positions, and I was hoping someone could point me in the right direction.
Thanks.

Have you found a solution? I have the same problem right now