Answers for "disable rigidbody unity"

C#
4

how to disable and enable rigidbody unity

// 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-***-*-*-*-*-*-
Posted by: Guest on April-27-2021
1

disable rigidbody unity

//This is for Unity (c#)
Rigidbody rb; //For 2D games use 'Rigidbody2D'
  
  void Awake ()
  {
      rb = GetComponent<Rigidbody>();
  }

  // (...)
rb.bodyType = RigidbodyType2D.Static;  // Deactivated
rb.bodyType = RigidbodyType2D./*The type the rigidbody was originally eg. dynamic, kinematic, or static*/; // Activated
Posted by: Guest on January-16-2021
0

unity rigidbody2d disable

//you can't :(
//you can delete it with
Destroy(RigidBody2D);
Posted by: Guest on January-02-2021

Code answers related to "disable rigidbody unity"

C# Answers by Framework

Browse Popular Code Answers by Language