I ve written a little function to check how steep the ground ist.
At 8 Points arround my player I check the GroundHeight and look at the highest and lowest point.
These point i tried to mark in game with a cube and a cone. So i thought i could easily check wethers it works or not. But in fact this objects are placed far away from my playermodel and get nearer when i walk towards them. And when I leave the terrain, Dark GDK crashes...
Does one have a hint for me?
void IsGroundSteep()
{
float x_temp[8];
float z_temp[8];
float y_temp[8];
float angle_temp[8];
float Hyp=15,min, max; //länge des Fühlers
int i,min_pos,max_pos;
angle_temp[0]= dbObjectAngleY(3) ;
for (i=1;i<8;i++)
angle_temp[i]= angle_temp[i-1] + 45;
for (i=0;i<8;i++)
{
float x_delta = sin(angle_temp[i])*Hyp;
float z_delta = cos(angle_temp[i])*Hyp;
x_temp[i]= x_pos + x_delta;
z_temp[i]=z_pos + z_delta;
y_temp[i]= dbGetTerrainGroundHeight(1,x_temp[i], z_temp[i]);
}
for (i=0;i<8;i++)
{
if (y_temp[i]< min)
{
min= y_temp[i];
min_pos=i;
}
if (y_temp[i]>max)
{
max = y_temp[i];
max_pos=i;
}
}
dbPositionObject (4,x_temp[max_pos], y_temp[max_pos], y_temp[max_pos]);
dbPositionObject (5,x_temp[min_pos], y_temp[min_pos], y_temp[min_pos]);
}