I have the following code in a FixedUpdate method in a C# ship control class I’m working on:
float heightAboveTerrain = transform.position.y -
(Terrain.activeTerrain.SampleHeight(transform.position) + Terrain.activeTerrain.transform.position.y);
This seems to give a reasonable value the first time it is called in a session, but subsequent calls always return the same value no matter where the ship moves. The terrain itself is based on Perlin noise, initialized before I start moving the ship. I can see hills and valleys, so I’m pretty sure that part is working right, and the ship is definitely moving (transform.position is changing).