When using ComplexCollisionMesh of StaticMesh asset, at the time of hit, the physical material refers to the material of the drawing mesh side using the material index of the collision mesh side.
Therefore, if the number of materials of the drawing mesh is less than the number of materials of the collision mesh, it will crash when hit.
Below is the modified code from Licensee. Confirmed that reflecting this will avoid crash.
void FBodyInstance::GetComplexPhysicalMaterials(const FBodyInstance*, TWeakObjectPtr<UPrimitiveComponent> OwnerComp, TArray<UPhysicalMaterial*>& OutPhysicalMaterials) { if(!GEngine || !GEngine->DefaultPhysMaterial) { UE_LOG(LogPhysics, Error, TEXT("FBodyInstance::GetComplexPhysicalMaterials : GEngine not initialized! Cannot call this during native CDO construction, wrap with if(!HasAnyFlags(RF_ClassDefaultObject)) or move out of constructor, material parameters will not be correct.")); return; } // See if the Material has a PhysicalMaterial UPrimitiveComponent* PrimComp = OwnerComp.Get(); if (PrimComp) { UStaticMeshComponent* StatComp = Cast<UStaticMeshComponent>(PrimComp); if(StatComp && StatComp->GetStaticMesh() && StatComp->GetStaticMesh()->ComplexCollisionMesh) { UStaticMesh* Mesh = StatComp->GetStaticMesh()->ComplexCollisionMesh; const int32 NumMaterials = Mesh->StaticMaterials.Num(); OutPhysicalMaterials.SetNum(NumMaterials); for (int32 MatIdx = 0; MatIdx < NumMaterials; MatIdx++) { UPhysicalMaterial* PhysMat = GEngine->DefaultPhysMaterial; UMaterialInterface* Material = Mesh->GetMaterial(MatIdx); if (Material) { PhysMat = Material->GetPhysicalMaterial(); } check(PhysMat != NULL); OutPhysicalMaterials[MatIdx] = PhysMat; } } else { const int32 NumMaterials = PrimComp->GetNumMaterials(); OutPhysicalMaterials.SetNum(NumMaterials); for (int32 MatIdx = 0; MatIdx < NumMaterials; MatIdx++) { UPhysicalMaterial* PhysMat = GEngine->DefaultPhysMaterial; UMaterialInterface* Material = PrimComp->GetMaterial(MatIdx); if (Material) { PhysMat = Material->GetPhysicalMaterial(); } check(PhysMat != NULL); OutPhysicalMaterials[MatIdx] = PhysMat; } } } }
I am not able to find world outliner how to enable it?
How can i modify the param name in EQS node
How to achieve HLSL Multiple Render Target in Material blueprints?
How does TextureRenderTarget2D get TArray<uint8> type data?
Undefined sysmbol: typeinfo for AActor when cross-compile linux dedicated server on windows
Trying to launch , erorr,dll missing
Why doesn't the collision diminish when the collision radius decreases?
What method is used to fill polygonal regions when drawing spline mesh at run time?
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-89830 in the post.
4 |
Component | UE - Simulation - Physics |
---|---|
Affects Versions | 4.23, 4.24 |
Created | Mar 2, 2020 |
---|---|
Resolved | Jul 19, 2022 |
Updated | Jul 19, 2022 |