Game Development Community

Distance to terrain surface

by Albert Steckenborn · in Torque Game Engine Advanced · 09/15/2006 (12:09 pm) · 2 replies

Hi, can anybody tell me or give me an advice how to detect the distance to my atlas 2 terrain surface from my object ?

void TestBox::processTick(const Move* move)
{

I need here a float value how height is my box over the atlas 2 terrain surface

}

For any advice i will be thankful

Greetings

#1
09/15/2006 (12:40 pm)
I am, by ZERO means, an expert, but in TGE (at the time that book was written), there is a function called getTerrainHeight(pos) that takes a 2D coordinate (of your object), and returns a numeric value of the terrain elevation at that location. I haven't tested it myself, but it's there in the TorqueScript.

Presumably, you could do:
%altitude = obj.Zvalue - getTerrainHeight(obj.position); or something of that sort (with proper syntax).
#2
09/15/2006 (2:39 pm)
Or you could cast a ray straight down.