2 registered members (Akow, tomaslolo),
1,536
guests, and 12
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
player movement (stairs)
#386140
10/29/11 12:47
10/29/11 12:47
|
Joined: Jul 2005
Posts: 1,930 Austria
Dark_samurai
OP
Serious User
|
OP
Serious User
Joined: Jul 2005
Posts: 1,930
Austria
|
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:
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
ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)! get free version
|
|
|
Re: player movement (stairs)
[Re: Dark_samurai]
#386144
10/29/11 13:51
10/29/11 13:51
|
Joined: Dec 2008
Posts: 1,660 North America
Redeemer
Serious User
|
Serious User
Joined: Dec 2008
Posts: 1,660
North America
|
More proof that the GS movement code sucks, eh? 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.
Last edited by Redeemer; 10/29/11 13:53.
|
|
|
Re: player movement (stairs)
[Re: Redeemer]
#386146
10/29/11 13:59
10/29/11 13:59
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
Senior Expert
|
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
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:
my.height = my.z + min_vec.z - target.z;
After all done, you can pull player down and make smooth movement, something like this:
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.
|
|
|
Re: player movement (stairs)
[Re: 3run]
#386210
10/30/11 19:43
10/30/11 19:43
|
Joined: Jul 2005
Posts: 1,930 Austria
Dark_samurai
OP
Serious User
|
OP
Serious User
Joined: Jul 2005
Posts: 1,930
Austria
|
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.
ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)! get free version
|
|
|
Re: player movement (stairs)
[Re: 3run]
#386403
11/02/11 13:07
11/02/11 13:07
|
Joined: Jul 2005
Posts: 1,930 Austria
Dark_samurai
OP
Serious User
|
OP
Serious User
Joined: Jul 2005
Posts: 1,930
Austria
|
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.
ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)! get free version
|
|
|
|