# gravity

> Returns the gravity acceleration vector expressed in the device's reference frame.

## Definition

* **Type:** Property
* **Namespace:** [UnityEngine](/engine/6000.5/script-reference/unityengine.md)
* **Assembly:** UnityEngine.InputLegacyModule

```csharp
public Vector3 gravity { get; }
```

### Remarks

This property returns [Vector3.zero](/engine/6000.5/script-reference/unityengine/vector3/zero.md) until the device delivers its first motion sample after the gyroscope is enabled. Read the gravity vector on a later frame, after the sensor has produced data.

### Examples

```csharp
using UnityEngine;

public class Example : MonoBehaviour
{
    float movementScale;

    void Start()
    {
        Input.gyro.enabled = true;
    }

    void Update()
    {
        // A "spirit level" - the dot product of the gravity and the Y axis (ie, Vector3.up)
        // is a measure of how far the device is from level on that axis (it will be zero
        // if the device is perfectly level). This value can be used to position an object
        // to act as the "bubble".
        Vector3 pos = transform.position;
        pos.y = Vector3.Dot(Input.gyro.gravity, Vector3.up) * movementScale;
        transform.position = pos;
    }
}
```
