Download

SetSimulatePhysics c++

Hello,

I have an actor. The root component is a statics mesh. Attached to that is another static mesh. In the BP, on default when the Actor is spawned “Simulate Physics” is false.
At some point I want to activate physics for that actor / mesh. If call:

mesh->SetSimulatePhysics(true)

Nothing happens. When I check the checkbox directly in the editor it works. Do I miss something?

Best

Can you show the exact code you’re running and where you’re running it from?
I’ve personally done it like this successfully before, from a component that was on the actor:

GetOwner()->FindComponentByClass<UStaticMeshComponent>()->SetSimulatePhysics(true);

I have been struggling with C++ changes not being detected by the editor after compiling sometimes though, so if you’re sure your code is good then it might be worth just closing the editor and building from VS and then re launching the editor to see if your changes now take effect