Legacy Documentation: Version 5.2
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Removed in version 5.2.1p2
Property rigidbody has been deprecated. Use GetComponent<Rigidbody>() instead. (UnityUpgradable)

Component.rigidbody

Switch to Manual
public Component rigidbody;

Description

The Rigidbody attached to this GameObject (null if there is none attached).

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Rigidbody rb = GetComponent<Rigidbody>(); void Example() { rb.AddForce(1, 1, 1); } }