Disable and Enable Actor physics

Hi! Happy new year! :slight_smile:

I am working on an inventory system. I can pick up items, it is placed in my inventory, and I can drop the items back into the world, all is fine, except for one thing; the mechanism I use is to not destroy the item that is put in the inventory, but to disable it and hide it. Then upon dropping the item, I am calling SetActorLocation, putting it in front of my character. This is all well and good but, my items have physics enabled, and if the item was in motion when I picked it up, then when I drop it, it still has that physics / momentum, and it drops to the ground moving in the same direction as it was moving when I picked it up.

I found a solution for this, which is before calling SetActorLocation, I can call DisableComponentsSimulatePhysics() on the actor. That works. But then, of course, when the item is dopped, it just hangs in the air - no physics. And I do not find an equivalent EnableComponentsSimulatePhysics() method on Actor.

So my question is, how can I either 1) remove all inertia / momentum from my actor, or 2) re-enable physics after I have disabled and placed my actor?

PS: This is in C++.


Disable physics on the root component. It should be as simple as actor->GetRootComponent()->SetSimulatePhysics( false );

And have an epic new year!

Perfect, thanks!


error C2039: ‘SetSimulatePhysics’: is not a member of ‘USceneComponent’

Use the Primitive Component

  1. UPrimitiveComponent*

  2. ///GetComponent()

  3. PhysicsActorBody->SetSimulatePhysics(true);