Skip to content

Instantly share code, notes, and snippets.

@GOROman
Created September 14, 2014 15:37
Show Gist options
  • Save GOROman/b2b3480df4da57e67eb9 to your computer and use it in GitHub Desktop.
Save GOROman/b2b3480df4da57e67eb9 to your computer and use it in GitHub Desktop.
配管工のオッサンをスタート時にTerrainに合わせよう
using UnityEngine;
using System.Collections;
public class SetPositionY : MonoBehaviour {
void Start () {
// スタート時のワールド座標での位置を取得
Vector3 pos = transform.position;
// 位置からTerrain上の高さを取得
float height = Terrain.activeTerrain.SampleHeight( pos );
// 高さをYへ反映
pos.y = height;
// 位置を書き換え
transform.position = pos;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment