Getting physics asset shape name from collision

Keeping it short, I need to find the name of the PhAT asset’s shape that registered the collision for locational damage purposes. I can get the bone name easily from a FHitResult of course, but I seem to not be able to find the way to get the actual shape attached to said bone. USkinnedMesh::GetPhysicsAsset() is as far as I get, but after that I’m stumped, there does not seem to be any clear way to get the shape nor its name. PhAT shapes are easy to rename in editor so we’d much prefer to use them for determining the hit location than bone names.

I imagine I’m just missing something or it’s not named clearly, constraints and just about any other info seems easy to fetch, so it feels like this should be too.

1 Like

Found it. In case anyone finds this looking for the answer as well, what you want is SkeletalMeshComponent->GetBodyInstance(FName BoneName)->BodySetup->AggGeom. Inside AggGeom there are several arrays for each type of shape, so you’ll have to check them for their name, as far as I know there’s no other way.

I noticed that this was kinda answered in How to read collision mesh data and primitives from a StaticMeshComponent in C++ - World Creation - Unreal Engine Forums only after finding this out, but it’s not quite the same. For a static mesh it seems you can just get the body setup, while a skeletal mesh has body instances on each bone, and in my case I needed to get a specific bone instance for the collision (which GetBodyInstance() allows you to do).

3 Likes

I found this and got excited but sadly I don’t see a way to get the name of the shape hit and the index always returns zero

For localized damage you can set a physics material to the collision body.

I’m using 8 physmats for my set up.

Each has “Flesh” assigned as the surface type.

To add surface types…
Project Settings → Engine → Physics → Physical Surfaces


Using the physmat for localized dmg

Using the physmat surface type you can apply specific impact V/A FX.