- Home /
Programmatically turn off gravity on rigidbody
I would like to turn off gravity after a specific event in my Unity game. Is there a way to turn off gravity programmatically?
thanks
Comment
Best Answer
Answer by shawnlehner · Jul 01, 2010 at 05:13 PM
In said event you would want to set the useGravity property of the rigidBody to false.
http://unity3d.com/support/documentation/ScriptReference/Rigidbody.html
Answer by creative72 · Jul 01, 2010 at 05:44 PM
use .useGravity
example
// Disables gravity on all rigid bodies entering this collider.
function OnTriggerEnter (other : Collider)
{
if (other.attachedRigidbody)
{
other.attachedRigidbody.useGravity = false;
}
}
// Turn this collider into a trigger on startup
collider.isTrigger = true;
Your answer
Follow this Question
Related Questions
Game Glitches and Cheat Codes 3 Answers
How to enable gravity on prefab after collision? 0 Answers
Disable Character Controller Gravity 1 Answer
Disable a script on collision 2 Answers
(C#)How To Disable Gravity From Script? 4 Answers