TerrainY not exact ?

Blitz3D Forums/Blitz3D Beginners Area/TerrainY not exact ?

Is there something wrong with TerrainY ? I tried keeping a character above the terrain with this command, but sometimes it sinks halfway through the floor.
When I use LinePick, it stays on the ground allways.
I tried to isolate the problem with this code:
; TerrainY Example
; ----------------
;It loads a terrain that is in the examples folder, if blitz is in Program Files\Blitz3d .. etc

Graphics3D 640,480
SetBuffer BackBuffer()

; Load terrain
terrain=LoadTerrain( "c:\program files\blitz3d\help\commands\3d_examples\media\height_map.bmp");game004/media/height44.bmp" )

; Scale terrain
ScaleEntity terrain,1,50,1

EntityPickMode terrain, 2

min# = 10000
max# = -min

For i# = 64 To TerrainSize(terrain) - 64 Step 0.1
	Cls
	Locate 0, 0
	Print "line: " + (TerrainSize(terrain) - i)
	Print "min: " + min
	Print "max: " + max
	Print 
	For j# = 64 To TerrainSize(terrain) - 64 Step 0.1
		
		LinePick i, 500, j, 0, -1000, 0
		
		v1# = TerrainY(terrain, i, 0, j)
		v2# = PickedY()
		v3# = Abs(v2 - v1)
		
		If v3 > max Then max = v3#
		If v3 < min Then min = v3#
		
	Next
Next

WaitKey()
End

And I noticed that there is a difference between TerrainY and LinePick. Has anybody experienced this before or is there something I am doing wrong ?

Use TerrainHeight() instead of TerrainY.

Don't forget to multiply the result by whatever you scaled the terrain by on the Y axis, since TerrainHeight returns a float between 0 and 1.