- Home /
What's the Rigidbody's gravity unit?
I want to make a physics simulator for school, and I want a rigidbody that makes a free fall by gravity force. (9,81 N).
When I apply to a cube the rigidbody, and set the mass to 4kg, it should take 0,5 seconds normaly to fall from a heigh of 10m. However, it needs 1+ seconds to fall, with every mass I put.(It's the same with 1kg and 1000000000 kg)
Why is this happening?
You should then know that mass is not a factor : In the fourth century B.C., Aristotle maintained that an object falls with a speed proportionate to its weight that is, the heavier the object, the faster it falls. This idea was generally accepted until the 17th century, when Galileo showed that the rate of fall caused by gravity is the same for all objects.
http://science.howstuffworks.com/falling-bodies-info.htm
anyway, in regard to your problem, I just did a test and I think you are correct! Here is my script, attach it to the rigidbody, set the rigidbody inspector to use gravity = false, is$$anonymous$$inematic = true. When you click the L$$anonymous$$B then is$$anonymous$$inematic is disabled and gravity is enabled, the object falls and the timer starts. When it hits something, the timer stops :
#pragma strict
var rigid : Rigidbody;
var isTi$$anonymous$$g : boolean = false;
var timer : float = 0.0;
function Start()
{
if ( !rigid )
{
rigid = this.gameObject.rigidbody;
}
}
function Update()
{
if ( Input.Get$$anonymous$$ouseButtonDown(0) )
{
rigid.is$$anonymous$$inematic = false;
rigid.useGravity = true;
isTi$$anonymous$$g = true;
}
if ( isTi$$anonymous$$g )
{
timer += Time.deltaTime;
}
}
function OnGUI()
{
GUI.Box( Rect( 10, 10, 100, 35 ), "" + rigid.velocity.magnitude.ToString() );
GUI.Box( Rect( 10, 55, 100, 35 ), "timer " + timer.ToString() );
}
function OnCollisionEnter( other : Collision )
{
isTi$$anonymous$$g = false;
}
Answer by $$anonymous$$ · Jan 06, 2013 at 07:12 PM
In fact no matter how heavy an object is, it takes equal amount of time for it to fall as any other object. Gravity in this perspective is not a "force" but an acceleration. It's value is not measured in Newton, but m/s^2, aka. acceleration. While I don't know exactly what units the underlying PhysX system works with, you can query (and set) the value for gravity with Physics.gravity
which is a Vector3
, and also visually in Edit / Project Settings / Physics.
You can also set a rigidbody's Drag property, which according to the docs corresponds to air resistance. 0 is no air resistance, and if it's infinity, the object stops moving.
I guess your best shot is to come up with a [gravity value, object mass, distance scale] combination that makes sense for you for a unit-weight object, and build your simulation based on that agreeable combination of values. (for example find a setting where your object falls in 0.5 seconds the desired distance (which may not be exactly 10 unity-units), and use that as the scale for everything else in your scene).
You can use alucardj's neat script for the timing.