how to add reference to rigidbody 2d
Code Example - how to add reference to rigidbody 2d
public Rigidbody2D rb;
unity rigid body variable
public Rigidbody rigidbody;
c sharp how to assign a rigidbody
GameObject myGameObject = new GameObject("Test Object"); // Make a new GO.
Rigidbody gameObjectsRigidBody = myGameObject.AddComponent<Rigidbody>(); // Add the rigidbody.
gameObjectsRigidBody.mass = 5; // Set the GO's mass to 5 via the Rigidbody.
rigidbody2d unity
Rigidbody2D rb;
// Can use Awake
void Start()
{
// Ataches the rigedbody that is on the gameObject to rb
rb = GetComponent<Rigidbody2D>();
}