// adjust entity to the ground height, using a downwards trace
if(c_trace(my.x,vector(my.x,my.y,my.z-5000),IGNORE_PASSABLE|IGNORE_ME) > 0)
dist_down= my.z + vFeet.z - hit.z; // always place player's feet on the ground
else
dist_down = 0;
if((dist_down > 0))
{
dist_down = clamp(dist_down,100,accelerate(speed_down,-nc_gravity * time_step,0.1));
}
else
{
//do the speed down to equal 0 so that he snaps to the ground
speed_down = 0;
if((dist_down + speed_down)> 0)
{
speed_down = - dist_down - 0;
}
if(key_space == 1)
{
jump_target = jump_height * time_step;
}
}
if(jump_target > 0)
{
speed_down = (sqrt((jump_target)* nc_gravity))*time_step;
jump_target -= speed_down ;
}