# SampleHeight(Vector3)

> Samples the height at the given position defined in world space, relative to the Terrain space.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.0/script-reference/unityengine.md)
* **Assembly:** UnityEngine.TerrainModule

```csharp
public float SampleHeight(Vector3 worldPosition)
```

### Parameters

**** (\[Vector3]\(/engine/6000.0/script-reference/unityengine/vector3)):&#x20;

### Returns

| Type                                                          | Description |
| ------------------------------------------------------------- | ----------- |
| [float](https://learn.microsoft.com/dotnet/api/system.single) |             |

### Remarks

This method automatically clamps the world position to the Terrain boundaries.

### Examples

```csharp
using UnityEngine;

public class ExampleScript : MonoBehaviour
{
    void LateUpdate()
    {
        Vector3 pos = transform.position;
        pos.y = Terrain.activeTerrain.SampleHeight(transform.position);
        transform.position = pos;
    }
}
```
