player movement (stairs)

Posted By: Dark_samurai

player movement (stairs) - 10/29/11 12:47

Hi,

I'm having constantly problems to make a player script with good behavior when it comes to gravity and climbing stairs.

A simple ego perspective player script without any gravity:
Code:
function control_player()
{
   while(my.skill1 > 0)
   {
       VECTOR move_dist;
       move_dist.x = (key_w - key_s) * 15 * time_step;
       move_dist.y = (key_a - key_d) * 15 * time_step;
       move_dist.z = 0;
       
       c_move(my, move_dist, NULL, GLIDE + IGNORE_PASSABLE);

       my.pan -= MOUSE_SENSIBILITY * mouse_force.x * time_step;

       vec_set(camera.x, my.x);
       camera.z += EYE_HIGHT;
       camera.pan = my.pan;
       camera.tilt += MOUSE_SENSIBILITY * mouse_force.y * time_step;

       wait(1);
   }
}



Now I wanted to know how you are implementing a good gravity system that allows to walk on stairs? I know that there are many ways how this can be done and I know that there are many threads about this topic but I didn't managed to get a good result with any of the informations I got.

I don't want to use PhysX and I don't want to write my own collision system. All I want to use is c_move() and c_trace(). Additionally the code shouldn't be too complex (it's not important that the result is 100% perfect).

Thanks for sharing your experiences laugh
Posted By: Pappenheimer

Re: player movement (stairs) - 10/29/11 13:51

Did you try the example from the manual?
I'm not sure, but I remembered that it works quite well, and it should work with stairs as well, because it reflects how Jcl thinks it is supposed to be written...
Posted By: Redeemer

Re: player movement (stairs) - 10/29/11 13:51

More proof that the GS movement code sucks, eh?

Originally Posted By: Dark_samurai
I don't want to use PhysX and I don't want to write my own collision system. All I want to use is c_move() and c_trace(). Additionally the code shouldn't be too complex (it's not important that the result is 100% perfect).

c_move and c_trace are next to useless unless you place invisible walls over each and every non-flat surface and generally pamper the system into submission. No matter which way you look at it you will end up with a complex solution. Unlike Quake's AABB, which is very robust, even a slightly acute surface in Gamestudio can cause tremendous problems to its built-in movement system.

EDIT: @Pappenheimer: JCL's solution doesn't solve many problems and opens several cans of worms on its own.
Posted By: 3run

Re: player movement (stairs) - 10/29/11 13:59

First, make downwards trace with USE_BOX set on. Second, use "vec_for_min" to get the lower vertex of the players model, and use the vector which is returned by it, to get distance to ground:
Code:
my.height = my.z + min_vec.z - target.z;

After all done, you can pull player down and make smooth movement, something like this:
Code:
absdist.z = -(my.height - 17); // 17 is dist to ground
absdist.z = maxv( -35 * time_step, absdist.z); // 35 is falling speed

I hope, this was usefull for you.
Posted By: Dark_samurai

Re: player movement (stairs) - 10/30/11 19:43

Thank you all for your answers!

I haven't known that there is an example in the manual. I tried it and with some small improvements I really liked the result! The example works the same way as 3run described it.
Posted By: 3run

Re: player movement (stairs) - 10/30/11 21:09

There is an other example of a little bit more complex gravity, which I've made with Superku, take a look at AUM 100, but it's old. If you need me to, I can share with you updated version, just send me a PM.
Posted By: Dark_samurai

Re: player movement (stairs) - 11/02/11 13:07

Thx for the offer, but I think my current solution works already good enough. As I said before, it don't need to be perfect but simple.
© 2024 lite-C Forums