I am trying to copy the Collision Meshes (in my case the convex decomposition collision meshes) from one StaticMesh to another StaticMesh.
After some looking around I read that the Collision Meshes are stored in the BodySetup and so I tired something like this:
UBodySetup* OldBodySetup = MyOldStaticMeshActor->GetStaticMeshComponent()->GetBodySetup(); FKAggregateGeom OldAggregateGeom = OldBodySetup->AggGeom; MyNewStaticMeshActor->GetStaticMeshComponent()->GetBodySetup()->AddCollisionFrom(OldAggregateGeom);
This works fine for simple collsion but with convex decomposition meshes I encounter a strange thing:
If I open the “receiver” static mesh (MyNewStaticMeshActor) in the editor, I can see in the collision section that there are indeed 10 Convex Elements, so the copy process worked but the collisions are not shown (see picture 1) and also not working.
But here comes the strange thing: As soon as I change ANY collision setting with the mouse pointer (like “Double Sided Geometry”, the collision meshes show up! (see picture 2).
So it seems that changing any setting in the collisions section in the editor “refreshes” something and that makes the collision meshes appear and also work.
Does anyone have a clue what to add to the code (the refreshing part) ???