PxRigidDynamic::setLinearVelocity: Body must be non-kinematic!

I have a mode where I’m doing some freezing and unfreezeing of blocks that stack during gameplay using physics. They are constrained on the X-Z plane.

Framerate sucks in development (fine in shipping)- and I get masses of this spew:

LogPhysics: Error: PHYSX: (D:\Build\++UE4+Release-4.17+PhysX_Compile\Sync\Engine\Source\ThirdParty\PhysX\PhysX_3.4\Source\PhysX\src\NpRigidDynamic.cpp 219) eINVALID_PARAMETER : PxRigidDynamic::setLinearVelocity: Body must be non-kinematic!

The framerate in dev builds is bad enough to make further development hard and I’d like to fix it.

The objects in question are static meshes with non colliding meshes attached to detect near overlaps.

Physics control is a mixture of C++ UE4 APIs and C++ calling BP functions to use BP library functions.

When spawned we:

  • disable simulation (BP SetSimulationPhysics(false))
  • disable collisions (UPrimitiveComponent::SetCollisionEnabled)
  • force zero velocity (UPrimitiveComponent::SetPhysicsLinearVelocity({0,0,0}, false))

later (dropping a block on the stack) we reverse these calls.

For the most part we let objects fall and do their simulated behavior.