Samples the height at the given position defined in world space, relative to the terrain space.
function LateUpdate () { transform.position.y = Terrain.activeTerrain.SampleHeight(transform.position); }
using UnityEngine;
public class ExampleScript : MonoBehaviour { void LateUpdate() { Vector3 pos = transform.position; pos.y = Terrain.activeTerrain.SampleHeight(transform.position); transform.position = pos; } }
Did you find this page useful? Please give it a rating: