# Getting the world position of skeletal mesh vertex

**URL:** <https://forums.unrealengine.com/t/getting-the-world-position-of-skeletal-mesh-vertex/386765>\
**Category:** World Creation\
**Tags:** physics-constraint, vertex-position, unreal-engine, Physics, skeletalmesh, CPP, question\
**Created:** [March 2, 2017, 10:33pm UTC](https://forums.unrealengine.com/t/getting-the-world-position-of-skeletal-mesh-vertex/386765 "2017-03-02T22:33:20Z")\
**Posts on this page:** 1\
**Showing post:** 32

<div class="post-metadata">

**Author:** ![J\_Escape](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@J\_Escape](https://forums.unrealengine.com/u/J_Escape)\
**Post date:** [June 9, 2024, 4:05am UTC](https://forums.unrealengine.com/t/getting-the-world-position-of-skeletal-mesh-vertex/386765/32 "2024-06-09T04:05:21Z")

</div>

Got it working in 5.4

```auto

#include "Rendering/SkeletalMeshRenderData.h"
#include "Engine/SkeletalMesh.h"
#include "SkeletalRenderPublic.h"

bool UCustomBP_Library::BP_GetSkeletalMeshVertexLocations(USkeletalMeshComponent* Mesh, TArray<FVector>& Locations, int32 LODIndex)
{
    if (!Mesh || !Mesh->GetSkeletalMeshAsset())
    {
        return false;
    }

    const FSkeletalMeshRenderData* RenderData = Mesh->GetSkeletalMeshRenderData();
    if (!RenderData)
    {
        return false;
    }

    const FSkeletalMeshLODRenderData& LOD = RenderData->LODRenderData[LODIndex];
    const FSkinWeightVertexBuffer& Buffer = LOD.SkinWeightVertexBuffer;
    TArray<FMatrix44f> CacheToLocals;
    Mesh->GetCurrentRefToLocalMatrices(CacheToLocals, LODIndex);

    if (Mesh->GetCPUSkinningEnabled())
    {
        // CPU skinning
        TArray<FFinalSkinVertex> SkinnedVertices;
        Mesh->GetCPUSkinnedVertices(SkinnedVertices, LODIndex);
        Locations.Empty();
        Locations.AddUninitialized(SkinnedVertices.Num());
        for (int32 i = 0; i < SkinnedVertices.Num(); ++i)
        {
            Locations[i] = FVector(SkinnedVertices[i].Position);
        }
    }
    else
    {
        // GPU skinning
        TArray<UE::Math::TVector<float>> SkinnedPositions;
        Mesh->ComputeSkinnedPositions(Mesh, SkinnedPositions, CacheToLocals, LOD, Buffer);
        Locations.Empty();
        Locations.AddUninitialized(SkinnedPositions.Num());
        for (int32 i = 0; i < SkinnedPositions.Num(); ++i)
        {
            Locations[i] = FVector(SkinnedPositions[i]);
        }
    }

    // Transform local positions to world positions
    const FTransform ToWorld = Mesh->GetComponentTransform();
    for (FVector& EachVertex : Locations)
    {
        EachVertex = ToWorld.TransformPosition(EachVertex);
    }

    return true;
}

void UCustomBP_Library::BP_SetCPUSkinningEnabled(USkinnedMeshComponent* Mesh, bool bEnable, bool bRecreateRenderStateImmediately)
{
    Mesh->SetCPUSkinningEnabled(bEnable, bRecreateRenderStateImmediately);
}

```

---

_[View the full topic](https://forums.unrealengine.com/t/getting-the-world-position-of-skeletal-mesh-vertex/386765)._
