- Home /
Question by
Raisgeir · Aug 06, 2017 at 04:01 PM ·
gameobjectterrainaltitude
How get the altitude of a gameobject above a terrain
Hello! I'm new to unity and I want to know how a gameobject's(aircraft) altitude is acquired based from its height above a given terrain. Thanks
Comment
Answer by tanoshimi · Aug 06, 2017 at 04:19 PM
Use SampleHeight to get the altitude of the terrain, and subtract that from the y coordinate of the object's transform position: https://docs.unity3d.com/ScriptReference/Terrain.SampleHeight.html
Your answer
Follow this Question
Related Questions
Gameobject collision with Terrain C# 4 Answers
GameObjects vs. Submeshes 2 Answers
Duplicating Terrain at run-time 2 Answers
Water and Terrain issues 0 Answers
GameObject going into terrain. 0 Answers