Skip to content

TerrainY

Narta Xaymar Dirks edited this page Oct 28, 2026 · 5 revisions
Blitz3D

TerrainY

TerrainY:Float32 terrain:Int32, world_x:Float32, world_y:Float32, world_z:Float32
Parameter Mode Type Default Description
terrain In Int32 required The terrain.
world_x In Float32 required
world_y In Float32 required
world_z In Float32 required

Returns: The world Y coordinate of the ground at that position.

Description

Gives the height of the ground at a point of the world, including the terrain's position, scale and the blending between grid points. The Y you pass in does not matter for an upright terrain. This is the simple way to keep something standing on the ground.

Examples

Graphics3D 320, 240, 0, 2
SetBuffer BackBuffer()
camera = CreateCamera()
CameraClsColor camera, 120, 160, 210
PositionEntity camera, 8, 11, -13
RotateEntity camera, 28, 0, 0
light = CreateLight()
RotateEntity light, 50, 20, 0

land = CreateTerrain(16)
ScaleEntity land, 1, 6, 1
EntityColor land, 90, 170, 80
For z = 0 To 16
	For x = 0 To 16
		ModifyTerrain land, x, z, 0.5 + 0.5 * Sin(x * 24) * Cos(z * 24)
	Next
Next

; Put a row of poles on the ground, whatever its height.
For x = 1 To 15 Step 2
	pole = CreateCylinder(8)
	ScaleEntity pole, 0.25, 1, 0.25
	z# = 8
	PositionEntity pole, x, TerrainY(land, x, 0, z) + 1, z
	EntityColor pole, 220, 70, 60
Next

RenderWorld
Flip
WaitKey

Media

TerrainY

Related Commands

CreateTerrain, LoadTerrain, TerrainDetail, TerrainHeight, TerrainShading, TerrainSize, TerrainX, TerrainZ

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally