Pause physics while re-positioning nodes

At a certain point in my game I need to reposition nodes that have rigidbody physics attached to them. When I use SetRotation the physics engine kicks in causes the nodes interact with other components in the scene. I would like to temporarily suspend the physics engine while I reposition the nodes and then turn it back on again. Any suggestions on how to do this?

Very easy. You can disable whole physics world or only certain components.
To disable whole physics world use:

auto* physicsWorld = node_->GetScene()->GetComponent<PhysicsWorld>();    

To disable physics of one object use:

auto* rigidBody = object->GetNode()->GetComponent<RigidBody>();

To enable it again set ‘true’ in these functions.


Also, you can stop the time.

Scene* scene = node_->GetScene();
1 Like

Thanks, this is just what I was looking for.

1 Like

Instead of Scene::SetTimeScale(float) you could also use Scene::SetUpdateEnabled(bool).