Hey there I have following problem: I wrote a spawnsystem and it works fine. There is still one problem i can't solve yet: How i can spawn enemys ON the terrain? How i get the height of one point from the terrain? I tried it with: Code (csharp): pos.y = Terrain.activeTerrain.terrainData.GetHeight(); but GetHeight only works for int variables and not for float (How it should). Thanks for help DubStep
Maybe: GetInterpolatedHeight(x: float, y: float): float; http://docs.unity3d.com/Documentation/ScriptReference/TerrainData.GetInterpolatedHeight.html
ok no i didn't know this command, but now it doesn't work, too. Code (csharp): pos.y = Terrain.activeTerrain.terrainData.GetInterpolatedHeight(pos.x,pos.z); this is my code for setting the "right" height. pos is a vector3. now: what is wrong whis this?
Oh, this is what you need to use: Terrain.SampleHeight http://docs.unity3d.com/Documentation/ScriptReference/Terrain.SampleHeight.html Note that it is relative to the terrain position, so you may need to take that into account depending on your terrain height. http://answers.unity3d.com/questions/37144/incorrect-height-with-sampleheight.html
Last time I looked, the terrain system docs were somewhat lacking, especially with heights and such. Been that way for a while. I can very much understand his confusion.