xxxxxxxxxx
// if you want to disable the rigidbody on which the script is sitting on
// you can't do that but you can go around it by
// Just destroying the rigidbody by calling
Destroy(gameObject.GetComponent<Rigidbody>());
// and if you want it again call
gameObject.AddComponent<Rigidbody>();
// Remember "gameObject" with small 'g' reffers to the gameObj on which the script
// is sitting on
// -*-*-*-*-*-***-HAPPY CODING-***-*-*-*-*-*-
xxxxxxxxxx
// This is for Unity (C#)
Rigidbody rb2D; // For 2D games, use 'Rigidbody2D'
Rigidbody rb3D; // For 3D games, use 'Rigidbody'
void Awake()
{
rb2D = GetComponent<Rigidbody2D>();
rb3D = GetComponent<Rigidbody>();
}
// (...)
// Disable Rigidbody for 2D games
rb2D.bodyType = RigidbodyType2D.Static;
// Enable Rigidbody for 2D games
rb2D.bodyType = RigidbodyType2D.Dynamic; // Replace with the original body type (e.g., Kinematic, Dynamic or Static)
rb3D.isKinematic = true; // Disable Rigidbody for 3D games
rb3D.isKinematic = false; // Enable Rigidbody for 3D games
xxxxxxxxxx
myPlayer.Getcomponent<Rigidbody>().isKenimatic == false;
myPlayer.Getcomponent<Rigidbody().detectCollision = true;
}