UProceduralMeshComponent and physics


i try to generate a mesh with the UProceduralMeshComponent and make it fall down using SimulatePhysics. In my Actors constructor i have this code:

myMesh = ObjectInitializer.CreateDefaultSubobject<UProceduralMeshComponent>(this, TEXT("myMesh"));
RootComponent = myMesh;

And then i am having a function to setup the physics:



But when i spawn the Actor in my scene it remains static even if it is supposed to fall down. What is my mistake? What is missing?


How are you generating the Mesh Vertices? Is it possible that you’re generating the vertices with an old transform? It could be that the ‘object’ itself is actually falling, but the mesh is being generated in the same location?

A good way to test this would be create a new actor with a PrimitiveComponent at the root, and your Procedural Mesh attached to that. Make sure you can preview the ‘Root’ in PIE and see if it drops during play. If it does and the mesh doesn’t, the problem is probably related to the transform of the ProceduralMeshComponent.

(This is all assuming that ProceduralMeshes can actually SimulatePhysics)

Thank you for your answer. I will try that later this day and hope that this is the reason.


So i did what you were suggesting and it worked, the cube was falling down with the procedural mesh attached to it. So i was adding this code to the Actors Tick function after removing the cube again:

if (myMesh)
	myMesh->SetWorldLocationAndRotation(this->GetTransform().GetLocation(), this->GetTransform().GetRotation());

But again, the mesh remains static. You did mention that all this is assuming that the ProceduralMeshComponent is capable to SimulatePhysics. How can i find out if this is the case? Or is there anything else wrong with my code?


Oh I’ve just thought of something, You’ll need a valid collision in order to simulate Physics on the object…

I bet if you print out whether the object is simulating physics or not, it’ll say ‘yes’ the first time when you set it, then ‘no’ after as Physics might be turning it off again.

I think you are right! At least if i check if it simulates physics it is false.

So i found out that the UProceduralMeshComponent already has functionality implemented. One of its members is a BodySetup.

So what i did then is to create a collision by doing:

myMesh->ProcMeshBodySetup->CollisionTraceFlag = CTF_UseComplexAsSimple;
myMesh->ProcMeshBodySetup->bMeshCollideAll = true;

Unfortunately no success. Still its IsSimulatingPhysics function is returning false. Has anyone ever used the UProceduralMeshComponent and its physics capabilities and made it work? I ask myself if it is actually working, because still the UProceduralMeshComponent is experimental.