Enable or Disable Rigid Body at Runtime?

Is it possible to enable/disable the rigid body component at runtime?

You probably just want to do .rigidbody.isKinematic = true.

In Unity 4.0+ rigidbody.active is deprecated and may no longer be available but you can do this:

rigidbody.detectionCollisions = false;

You can't enable or disable rigidbody, but you can destroy it with Destroy and add it back with AddComponent.

Ref: Unity - Scripting API: Rigidbody.isKinematic

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public Rigidbody rb;
    void Start() {
        rb = GetComponent<Rigidbody>();
    void EnableRagdoll() {
        rb.isKinematic = false;
        rb.detectCollisions = true;
    void DisableRagdoll() {
        rb.isKinematic = true;
        rb.detectCollisions = false;
}enter code here

can we add “Add Component” on the selected game object we want? how?

GetComponent().simulated = false;

you can destroy component

Destroy (rigidbody);

or change body type to Kinematic

rigidbody.isKinematic = true;

any way to do this for 2D?

you CAN disable a rigidbody by doing this:

rigidbody.active = false;