campfire/Assets/Scripts/TerrainModelPlacer.cs

17 lines
560 B
C#
Raw Permalink Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteAlways]
public class TerrainModelPlacer : MonoBehaviour {
private void Update() {
2020-04-20 02:38:37 +02:00
if (!Application.isPlaying) {
// Update is called in editor when values change
2020-05-03 23:09:44 +02:00
Terrain Terrain = GameObject.FindGameObjectWithTag("Main Terrain").GetComponent<Terrain>();
Vector3 Pos = transform.position;
Pos.y = Terrain.transform.position.y + Terrain.SampleHeight(Pos);
transform.position = Pos;
}
}
}