Download

Correct way to create staticmesh physics actors

Hi, I have question.
What I want to do is make a blueprint actor with a staticmesh that has physics simulation. For testing I’m using a cylinder basic shape now.
When you first create a blueprint actor it already has a default scene root. So I can add static mesh to that, and set it to simulate physics. What I noticed is that when I run the game and the mesh starts falling, the location of the actor doesn’t seem to change. That seems odd to me.
For example when I draw a debug string and attach it to the actor, it doesn’t move with the static mesh, but it stays on the origin of the actor, which doesn’t move with the simulated physics mesh.

So is this how it is supposed to be? I noticed that I can also make the static mesh the root of the actor, then it seems more logical, in that the location of the actor moves with the mesh. A down size of this is that I cannot place the static mesh in a rotated manner inside the actor. I would have to rotate the actual actor to make the test-cylinder face the direction I want.

So what is the ‘correct’ way of making actors that consist of a mesh with physics simulated? Or ‘how do you prefer to do it’ ?

Thanks for any input!

Yes, that’s how it’s supposed to be. Physics-simulated meshes don’t care about the usual parenting transform stuff, since the two are mutually exclusive. If you want to attach simulated meshes together you can use auto weld, or physics constraints. Setting the mesh as the root is how I generally do it, it’s easier and less confusing. You never have to worry about finding the right mesh component and getting the location of that, etc. Presumably your final game meshes will be imported with the correct rotation and consistent axes. If you wanted to use the same mesh rotated differently in different blueprints you could use the construction script.

How to activate physics simulation on static mesh actors via c++ ?

You can do it via getting the UStaticMeshComponent and calling SetSimulatePhysics. The following would turn it on.


UStaticMeshComponent *Mesh = GetStaticMeshComponent();
Mesh->SetSimulatePhysics(true);