SampleHeight(Vector3)
Samples the height at the given position defined in world space, relative to the Terrain space.
Read time 1 minuteLast updated 4 days ago
Definition
- Type: Method
- Namespace: UnityEngine
- Assembly: UnityEngine.TerrainModule
public float SampleHeight(Vector3 worldPosition)
Parameters
Returns
Type | Description |
|---|---|
| float |
Remarks
This method automatically clamps the world position to the Terrain boundaries.
Examples
using UnityEngine;public class ExampleScript : MonoBehaviour{ void LateUpdate() { Vector3 pos = transform.position; pos.y = Terrain.activeTerrain.SampleHeight(transform.position); transform.position = pos; }}