For my movement I use a cube for collision, and then a passable model for the actual detail. This also allows my passable model to have independent rotation and the such. I keep the cube off the ground at all times using trace with the set_box flag. Some people believe it's best to let your entity drag along the ground, I haven't tried this so cannot comment. But I find that tracing downwards, and just changing your angle depending on ground normals work well. Also, have the movement friction set very low. It works quite well, and have not had any problems with the majority of static geometry.
- Be sure to use c_rotate() for any rotations.
- Be sure to use c_move() for any movement, that includes any z movement or changes in your z pos. I know when I had problems with the model catching, it often was from me moving, even subtly, the model without c_move().
Heres what I set in the begging of function for the collision cube:
//my.fat = on;
//my.narrow = on;
c_setminmax(my);
ph_setgravity(vector(0,0,-gravity));
my.polygon = off;
move_min_z = -1;
move_friction =0.25;
Disable_Z_Glide = 0;
Heres what I use for my static geometry:
wait(1);
my.fat = on;
my.narrow = on;
c_setminmax(me);
my.polygon = on;
wait(300);
my.dynamic = off;
And if you want your model to update it's collision realtime(only for per-poly models):
while(1)
{
c_updatehull(my, 1);
wait(1);
}
I basically have 1 c_rotate and 1 c_move() in my collision cubes function, all the different forces add up into the vector I use to move/rotate by, I also use movement in absolute coordinates:
move.tilt = ang(you.tilt - my.tilt);
move.roll = ang(you.rroll - my.roll);
you.kturn_speed = turn_direction * turn_gear * turn_sharp * skid_turn * air_turn; you.kturn_speed *= player_lock;
move.pan = turn_direction * turn_gear * turn_sharp * skid_turn * air_turn * you.ion_puller * time;
c_rotate(my,move.pan,ignore_passable + ignore_passents + glide);
move.x = run_speed * run_direction * air_speed * skid_forward * time;
move.y = skid_slide * time; you.kslide_speed = skid_slide;
vec_set(temp.x, nullvector); temp.pan = my.pan; temp.roll = you.rroll; temp.tilt = my.tilt;
vec_rotate(move.x, temp.pan);
move.z = z_movement;
c_move(my,nullvector,move.x,ignore_passable + ignore_passents + glide + ignore_content);
Hopefully this helps. The collision system works quite well, it just takes a while to get the code right. The physics engine though, well, I wouldn't recommend it for bigger projects, best to just use c_move().