Changing physics asset material based on player equipment

Meshes have their physical properties like phys material determined by editor Physics Assets which apply to all instances of that mesh. However, there are gameplay events that may make an individual instance of a mesh differ from the original asset. A character mesh might have a default physics material of Flesh by default, but once the player starts to equip a metal chestplate, cloth greaves, or leather vambraces, the physics material needs to change.

However, each physics body has data like its physics material stored in a UBodySetup. This data is shared for optimization purposes across all instances of the physics bodies:

 * BodySetup contains all collision information that is associated with a single asset.
 * A single BodySetup instance is shared among many BodyInstances so that geometry data is not duplicated.

which means I can’t change it on a per-instance basis. Is there a way to have accurate physics materials for my character mesh without generating physics assets for every possible permutation of equipment choice by the player?

It looks like there is a phys material override just for this. I can get each physics body in the skeletal mesh and set their materials individually like

mesh->GetBodyInstance(FName(TEXT("spine_02")), false)->SetPhysMaterialOverride(steelPhysMaterial);
mesh->GetBodyInstance(FName(TEXT("spine_03")), false)->SetPhysMaterialOverride(steelPhysMaterial);
mesh->GetBodyInstance(FName(TEXT("spine_04")), false)->SetPhysMaterialOverride(steelPhysMaterial);
mesh->GetBodyInstance(FName(TEXT("spine_05")), false)->SetPhysMaterialOverride(steelPhysMaterial);
mesh->GetBodyInstance(FName(TEXT("head")), false)->SetPhysMaterialOverride(leatherPhysMaterial);

None of this is exposed to blueprints as of Unreal 5.5, so if you need them there then you will need to create your own blueprint helper in C++.

First of. No one should be using blurint if not for prototyping purposes.
If you are coding a game use actual code ffs.

Secondly, no one really does it the way you describe.

Even in blueprint:
Hit > break hit result > get material info.

If your character has properly made assets, even with runtime merge on the mesh you are able to get the immidiate element that is at the point of impact just from the impact result.

You can likely base your output just on the material slot name if you use good naming conventions.

However, the intended way is to add physical material maps to everything that needs it - built in such a way that each pixel of the UV can respond differently as a material based on whatever the designer/artist sets up.

Runtime merge ofc does not optimize things to where you have a proper asset with just one material slot.
Doing that is something your character development team needs to do by manually creating merged maps/assets with a focus on performance
(And as far as industry goes, it isn’t very common. Player characters stay modualr and incur the costs on most games, when they cant they are just merged at runtime).

So, you probably do not want to set the physical material on the object(s), but rather, you want to create and set their physical material Map instead.

With skeletal merge it has always discarded the physicsassets for me

Doesn’t this only work for complex collisions? Isn’t it good for the physics bodies to have the proper phys material for when you only need simple collisions?

It is, naturally, but if you are attempting to deal with modular characters, then your system can’t be “easy” so to speak.

Ideally, you would get the system to where it produces a UV driven composite map. Again, this is utterly impractical and would require massive amount of artist work to achieve (since generally assets have individual UVs and not a general overall map).