Accessing the Rigidbody Component Through Scripts
Last updated
Last updated
Rigidbody components can be accessed like any other component.
Example of storing the Rigidbody component in a variable:
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:
Here are some example scripts to access the properties: