Accessing the Rigidbody Component Through Scripts

Overview

Rigidbody components can be accessed like any other component.

Example of storing the Rigidbody component in a variable:

public Rigidbody thingRb;

In the Inspector, the object with the script attached will have the component for the script and this property:

You can click and drag an object with a Rigidbody component into the field or click the circle target icon on the right to select from a list.

If you want to have Rigidbody component of the object the script is attached to be stored, use this script in the Start() function:

Commonly Accessed Properties

Here are some example scripts to access the properties:

Last updated

Was this helpful?