Created
September 14, 2014 15:37
-
-
Save GOROman/b2b3480df4da57e67eb9 to your computer and use it in GitHub Desktop.
配管工のオッサンをスタート時にTerrainに合わせよう
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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