Game Development Community

Player fall off and get falling below the ground surface

by Nabarro · in Torque Game Engine · 02/02/2008 (4:08 am) · 2 replies

Hellow everybody,

I came accross one problem with the Mission area editor:
When I click on some places in the mission edit area with my mouse, generally, the player will fall down to the point where my mouse clicks. But in some places, the player will get falling off continuously below the terrain surface. It seems that the player's new z value is less than the terrain height value of the clicked point.

I've checked the related code,
In ~\editor\missionAreaEditor.cc:
In function: void MissionAreaEditor::setControlObjPos(const Point2F & pos)
From about line 895~ 901:
if(bool(mTerrainBlock))
{
F32 height;
mTerrainBlock->getHeight(pos, &height);
if(current.z < height)
current.z = height + 10.f;
}

From the statement above, the player's new Z value(current.z) must be bigger than the terrain height of the clicked point(height), but why the player will fall off from the gound and get falling continuously below the terrain surface?

The height value is correct which is got by calling getHeight()?

Anyone may help?


Thanks,

#1
02/02/2008 (7:22 am)
The collision detection works by assuming all players start a little bit above the terrain and so they fall a bit before they start. If you move your players feet below the terrain you are creating a situation in a game that never usually happens, unless of course you made a hole, or a tunnel - which is what you want.

The short answer is, it's designed this way, and whenever the player goes below ground, you need to add objects for the player to fall on.
#2
02/02/2008 (6:35 pm)
Thanks Andy,

" If you move your players feet below the terrain you are creating a situation in a game that never usually happens, unless of course you made a hole, or a tunnel - which is what you want"

I make sure I didn't create any hole, or tunnel etc. It just fall off from the ground surface where the player came accross one high mountain(where we can see clearly that the player's feet is embedded into the mountain), so the player's feet is below the terrain surface and the player begin to fall off.

My problem is:
From the code above:
if(bool(mTerrainBlock))
{
F32 height;
mTerrainBlock->getHeight(pos, &height);
if(current.z < height)
current.z = height + 10.f;
}


These statement makes sure that current.z(player's height) is bigger than height(terrain surface height where the player is going to stand). So, the player should always stand above the terrain surface and it's impossible to fall off from the ground surface.

Is it possible that 10.f is not enough(current.z = height + 10.f;) or the got terrain surface height value is not correct by calling "mTerrainBlock->getHeight(pos, &height);"?

Please point it out,

Thanks,