After loading the terrain, use EntityPickMode land, 2.
Then, instead of using TerrainY, first call
LinePick ex, 2000, ez, 0, -4000, 0
And use PickedY() + 1.5 as the y-coordinate of the tank.
To align the tank to the terrain, use
AlignToVector player, PickedNX(), PickedNY(), PickedNZ(), 2, 0.1
after the linepick.
"0.1" means that the Align should be gradually applied. It should be a value between 0.0 and 1.0
Then, instead of using TerrainY, first call
LinePick ex, 2000, ez, 0, -4000, 0
And use PickedY() + 1.5 as the y-coordinate of the tank.
To align the tank to the terrain, use
AlignToVector player, PickedNX(), PickedNY(), PickedNZ(), 2, 0.1
after the linepick.
"0.1" means that the Align should be gradually applied. It should be a value between 0.0 and 1.0