Unity has a function Terrain.sampleHeight(point)
which is great, it instantly gives you the height of the Terrain underfoot rather than having to cast.
However, any non-trivial project has more than one Terrain. (Indeed any physically large scene inevitably features terrain stitching, one way or another.)
Unity has a function Terrain.activeTerrain
which - I'm not making this up - gives you: the "first one loaded"
Obviously that is completely useless.
Is fact, is there a fast way to get the Terrain "under you"? You can then use the fast function .sampleHeight
?
{Please note, of course, you could ... cast to find a Terrain under you! But you would then have your altitude so there's no need to worry about .sampleHeight
!}
In short is there a matching function to use with sampleHeight
which lets that function know which Terrain to use for a given xyz?
(Or indeed, is sampleHeight
just a fairly useless demo function, usable only in demos with one Terrain?)
It turns out the answer is simply NO, Unity does not provide such a function.