This is a very simple contribution.

I've had some problems with stairs and slopes with the new OBB c_trace collision.
The problem is that the stairsteps will return normals that look like a slope.
This didn't happen with the traditional AABB collision because the AABB box is 'straight', and the new OBB is a spheroid. So the normal returned depends on the point in the spheroid that hits the level geometry.

But, while the player is running on a slope, the normal is constant, and while running up a staircase, the returning normals change all the time. See the blue arrows in the fourth image below: they are all different because they are calculated after different points on the OBB 'perimeter' hitting the stairstep edges.



the use of move_min_z and disable_z_glide doesn't help much because it doesn't differentiate stairs from slopes. (it's also based in collision normals).

I found out that, if you start a c_trace from some quants below the player, it returns a different normal value. So in this code, I'm just using a second c_trace to tell stairs from slopes. If the normal.z values are different, we are standing on stairs.


Code:

vec_set(mG_tempvec.x,my.x);
mG_tempvec.z -=200; //trace 200 quants below (floor)

mActor_height = c_trace(my.x,mG_tempvec.x,
ignore_me + activate_sonar +use_box); //normal first trace

slopecheck = off;
if (normal.z < 0.45) //Potential slope. You may raise this value for less tolerance to slopes
{
oldnormalz = normal.z;
//start a second trace 8 quants below the player origin
c_trace(vector(my.x,my.y,my.z-8), mG_tempvec.x,
ignore_me + activate_sonar +use_box);

if (abs(normal.z - oldnormalz) >0.01)
{
slopecheck = off;
}
else
{
slopecheck = on;
}
}

if (mActor_height>2 || slopecheck)
{
//player is on the air OR a slope. Apply gravity
}
else
{
//player is on ground or stairs. Move freely.
}



Emilio

Last edited by eleroux; 10/03/06 02:32.