Hello, I have written the following code for an RTS-style camera, which works “well”, but not exactly how I want.
function LateUpdate()
{
var currentHeight = Terrain.activeTerrain.SampleHeight(transform.position);
transform.position.y = currentHeight + 90;
}
Basically, it constantly detects the height of the terrain under the camera and keeps it 90 units above it. But it adjusts the height too quickly, thus if the terrain is jittery, the camera will feel jittery (e.g. it’s only as smooth as the terrain is).
Below is an illustration of what I would like, but I’m not sure how to do it. Any thoughts?