Stopping physics/update like Unity pause button.

I am currently working on a networked game, and am need to do real-time debugging, but because things can happen on the server, and the client separately, and then things like destruction, and such being RPC I would like to have something in place where I can press a GUI button, and literally have the same functionality as the Unity Pause button. I don’t feel I need to duplicate the play until next frame button, but just the Pause button.

is there anyway to create such a GUI button to stop physics/update from firing?

1 Answer

1

You can set the fixedDeltaTime to 0 to stop any physics code from being processed. Apart from that if I were you, I would define a static bool and in all the update methods I would do this;

private void Update() {
    if(!isUpdate) return;

    // Rest of your code here
}