ドキュメント

Unity Engine

Download Unity

Unity Engine

SampleHeight(Vector3)

Samples the height at the given position defined in world space, relative to the Terrain space.
読み終わるまでの所要時間 1 分最終更新 1ヶ月前

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.TerrainModule
public float SampleHeight(Vector3 worldPosition)

Parameters

worldPosition

The position, in world space, to sample the height at.

Returns

Type

Description

floatThe height of the terrain at the given position, in world space units.

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; }}