How to pause/stop & resume/start physics simulation? (SOLVED)

I need to implement pause in my game. How to pause and resume the physics simulation?

I thought I can send a message to @physics: but there are no documentation about message ids.

You do it by sending a set_time_step message:
http://www.defold.com/ref/collection-proxy#set_time_step
Collection proxy manual

2 Likes

It works. Thank you.

Hello, noob here. I am running into the same problem. This topic is marked as solved but unfortunately the link to the solution is dead. Can someone tell me how to pause/resume physics? I want to do this from the main collection to the main collection.

I tried with:

  • msg.post("@physics", "set_time_step", {factor = 0, mode = 1})
  • msg.post("main", "set_time_step", {factor = 0, mode = 1})
  • msg.post("", "set_time_step", {factor = 0, mode = 1})

in function init(self)

The solution presented in this post sets the timestep for a loaded collection (through a collection proxy). You set the timestep on the proxy component.