[5.1] Calling SetSimulatePhysics has no effect until manually recreating physics state

I have code in my project to switch characters between ragdoll mode and normal mode. When I switch between them, I call GetMesh()->SetSimulatePhysics(...) with true and false respectively.

The issue is that this call has zero effect, unless I manually recreate the physics state afterwards by calling GetMesh()->RecreatePhysicsState()

If I run in PIE, enter ragdoll mode (without calling recreatephysicsstate), and then inspect the mesh in the details panel, the bSimulatePhysics is true. If I then toggle that property in the details panel, so that its off, it starts simulaing physics… And it still simulatesif i again toggle it back on. Which is really odd behaviour.

If I dont add theRecreatePhysicsState workaround while exiting ragdoll mode, while bSimulatePhysics IS becoming false, a following call to attach the mesh in question to another component silently fails (likely because its still considered being simulated).

If I add the RecreatePhysicsState workaround, any impulses that are added in the same frame have no effect (with no warnings in log).

I didnt have this issue with 5.1 preview 2, but it happened sometime soon after I upgraded to the 5.1 release.

So I managed to solve it for now, however I think there is an apparent engine bug involved.

Prior to experiencing this issue, I had reimported a mesh (lets call him SK_Jeff), and then in another folder I imported it again to get new a skeleton, and also created a new physics asset. Then I moved this new skeleton and physics asset into the folder with Jeff, and more or less replaced the old skeleton and physics asset with the new ones (for the newly reimported SK_Jeff).

This process seems to have broken the physics engine completely for these assets.

Removing all assets, and recreating them from scratch resolved the problem completely.

1 Like