How do I find y value on terrain ground?
Hi there, i am new to Unity and want to set my GameObject on the ground. Therefore i have a x and z coordinate but i do not know how to find out the right y. I have imported a real world Terrain and can calculate the right x and z value on it. Now i try to get the y value for the Terrain ground but my GameObject is always in the air at 761.8. In my FixedUpdate I do this:
Vector 3 pos = new Vector3(newX, 0, newZ); //newX and newZ are calculated earlier and correct float newY = Terrain.activeTerrain.SampleHeight(pos); //I found this in another Forum Thread pos.y = newY; transform.Position = pos;
For my Scene i created the Terrain with the WorldComposer Asset which creates a real world heightmap and satellite Images as textures above it.
Your answer
Follow this Question
Related Questions
Character Tilt When Imported from Blender to Unity 1 Answer
How can I correctly generate Button objects with C# script? 1 Answer
sprite animation change position webgl issue 2 Answers
Issue with player position on 3-lane track 0 Answers
How to convert Three.js model position into unity inside? 0 Answers