How to get vertex X/Y/Z from Static Mesh via Blueprint?

I want to be able to place hit boxes at specific vertices so I can later :-
(1) Detect hits at these locations and
(2) Reposition the whole mesh to somewhere else in the world so that the chosen (hit) vertex matches a new target location while maintaining its current rotation.

There may even be a better way to achieve this - so if anyone has any ideas, I’d love to hear them.

I’m also new to UE so if anyone has any potential solution, I ask that they explain it like they’re talking to their dog coz that’s just about how smart I am with UE and BPs at the moment.

Thanks.

In BP’s I think the easiest way would be to use sockets instead of VertexData.
Sockets allow you to specifiy a location and rotation relative to the Mesh’s transform and gets transformed automatically when the mesh is moved/rotated.

To create a socket, double click your StaticMesh in the content browers, then do

After creating the socket you can either directly attach your colliders to the sockets or do it dynamically in BP.

More on the matter in the [docs][2] and [this for SkeletalMeshes][3]

I think DennyR has the right approach if you want to attach a collider for hit detection.

Alternatively, though, you can get vertex and other geometry data for a static mesh by calling GetSectionFromStaticMesh in your blueprint and passing it the Static Mesh from a StaticMeshComponent. Using GetSectionFromStaticMesh requires that your StaticMesh has the ‘Allow CPUAccess’ Static Mesh Setting enabled.

Remember, a StaticMeshComponent in your blueprint owns a StaticMesh, so you need to call Get Static Mesh on the component to access the actual static mesh in your blueprint.

The vertex data that is returned from GetSectionFromStaticMesh is in Mesh local coordinates, not actor or world coordinates. In order to convert a world coordinate to mesh local, or mesh local to world, you need to get the transform for your component and apply it to go mesh-to-world, or apply its inverse to go world-to-mesh. I’ve attached a couple screenshots where I’ve used these transforms as a go-by.

With the vertex data you could manually position other objects in an actor so they line up with specific vertices on your static mesh. You could also take a world location and use it find nearby mesh vertices, etc. Keep in mind if you’re doing collision or line traces against a static mesh component that it uses collision geometry for that, which may be a bit different from your static mesh’s visible triangles. You also will need to roll your own way of picking vertices you care about out of the static mesh’s vertex array. Depending on what you want to do it could be a bit tricky.

Using the static mesh vertex data gives you a lot of flexibility, but it sounds like DennyR’s socket approach may be simpler to implement and give you the behavior you want.

Hi Spork, I just wanted to say a huge thank you for sharing this information on how to access a mesh’s vertices. It was extremely helpful!!

-Adam

SporkAlmighty, thank you for usefull respond!

SporkAlmighty, thank you very much!!! Your first screenshot solved my problem with getting world location of vertices! THX A LOT!