Horje
unity stop physics Code Example
unity stop physics
//if you have multiple scenes running concurrently and want to stop some of them
bool isRunning = false;
Scene _currScene;
PhysicsScene _physicsScene;

void start()
{
  //first disable auto simualtion and control 
  //control when do you want the simulation to 
  //run by a boolean
   Physics.autoSimulation = false;
   isRunning = true;
  //get the physics scene that you want it to be running 
  _currScene = SceneManager.GetActiveScene();
  _physicsScene = _currScene.GetPhysicsScene();
  // a boolean to stop the physcis in a scene
 
}
void FixedUpdate()
{
  if (_currScene.IsValid() && isRunning )
    {
      _physicsScene.Simulate(Time.deltaTime);
    }
}
void disablePhysics(){ isRunning = false;}
void enablePhysics(){ isRunning = true;}

// another way to stop the physics is by changing the time scale from 1 to 0 
void disablePhysics(){ Time.timeScale = 0;}
void enablePhysics(){ Time.timeScale = 1;}
// remember that anything that moves in the scene using methods that you coded
//must be linked to Time.deltaTime so you don't end up with some objects out of sync
//check the source for more info




Csharp

Related
unity change fixed timestep in code Code Example unity change fixed timestep in code Code Example
list array Code Example list array Code Example
c# windows service .net core Code Example c# windows service .net core Code Example
List<object>  foreach Code Example List<object> foreach Code Example
c# response.contenttype set filename Code Example c# response.contenttype set filename Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
13