Stop physics without using Time.timeScale = 0?

Short of makinga ll bodies in a scene static is it possible to stop physics updates from happening without disabling time altogether?

Well you can set a Rigidbody’s Is Kinematic property to true to stop its automatic world interaction.

There’s many cases in which that would not suffice, but perhaps in your case it’s enough.

Whenever you want to ‘stop motion’, you will need to cycle all relevant scene objects and their Rigidbodies, and set their IsKinematic attribute to true.

For me the problem was a little more complex :
I had to pause a Gameobject’s Rigidbody and resume it in order to have an animated pause menu.

So, to fix it I proceed as follows :

  1. Save your rigidbody.velocity (instance)
  2. Pause the rigidbody using rigidbody.Sleep() or rigidbody.isKinematic = true (both on your rigidbody instance)
  3. Wait until the player wants to resume…
  4. Resume the rigidbody using rigidbody.WakeUp() or rigidbody.isKinematic = false (both on your rigidbody instance)
  5. Set up your rigidbody.velocity (instance) with the one you saved at the first step

Here is an exemple :

using UnityEngine;
using System.Collections;

public class Example : MonoBehaviour {

    private Vector3 velocity;
    void Update () {
		if (Input.GetKeyDown(KeyCode.Space)) {
			// Pause the game when the player hit the Space key
			velocity = rigidbody.velocity;
			rigidbody.isKinematic = true;
		} else if (Input.GetKeyUp(KeyCode.Space)) {
			// Resume the game when the player release the Space key
			rigidbody.isKinematic = false;
			rigidbody.velocity = velocity;

I think it is possible to set the global Physics.sleepVelocity and Physics.sleepAngularVelocity to very high. this way your rigidbodies will fall asleep ignoring the system. But in order to get them back, you need to Awake all your rigidbodies I guess after setting the sleep parameters back.

Edit->Project Settings->Physics->auto simulation unable

There are many ways to make an object static, the following are in my opinion the best:

Roamcel’s method doesn’t actually help performance, since you would making the objects kinematic will make it have to check for collisions regardless.

Martijn Hendriks’s method is fine but not the greatest. If you were to go down this path you would be better off setting these settings indiviudally. Rigidbody.sleepAngularVelocity and Rigidbody.sleepVelocity.

For those who what to pause 2D engine programmatically without changing properties RigidBody2D and whatsoever, just use:

Physics2D.autoSimulation = false;// to pause


Physics2D.autoSimulation = true;// to resume.

In my case, Sleep() was not enough as the objects can start moving even if not set to Wake() yet. What worked for me is saving the Rigidbody velocity and angular velocity and then setting the freeze constraints. That way you don’t need to change anything else in the program.

Here is the code:

void Animate(bool on) 
    if (on)
        rb.constraints = RigidbodyConstraints.None;
        // Restore velocities
        rb.velocity = savedVelocity;
        rb.angularVelocity =  savedAngularVelocity;
        //Save current velocities
        savedVelocity = rb.velocity;
        savedAngularVelocity = rb.angularVelocity;
        rb.constraints = RigidbodyConstraints.FreezeAll;