Legacy Documentation: Version 5.1
LanguageEnglish
  • C#
  • JS

Script language

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

Rigidbody.useGravity

Switch to Manual
public var useGravity: bool;

Description

Controls whether gravity affects this rigidbody.

If set to false the rigidbody will behave as in outer space.

var coll: Collider;

function Start() { coll = GetComponent.<Collider>(); coll.isTrigger = true; }

// Disables gravity on all rigidbodies entering this collider. function OnTriggerEnter(other: Collider) { if (other.attachedRigidbody) { other.attachedRigidbody.useGravity = false; } }