Player 1st-Person with Gravity

Posted By: CD_saber

Player 1st-Person with Gravity - 02/14/08 17:32

Hello,

i need a 1st-person-Player script, which works with mdl-terrains. It would be kind if someone can help me out of this. The player should be able to walk foward/backward , strafe and to be pulled down by gravity.

Thanks in advance!
CD_SABER
Posted By: Metal_Man

Re: Player 1st-Person with Gravity - 02/14/08 21:13

this should work if you're using A6

Code:


action player_ent
{
var input_vec[3];
var Vz = 0;
var jump_able = 1;
camera.genius = me;
while(1)
{
input_vec.x = (key_w - key_s) * time * 5;
input_vec.y = (key_d - key_a) * time * -5;
Vz += (Vz == 0) * 25 * key_space * jump_able;
if(Vz > 0)
{
jump_able = 0;
}
Vz -= (Vz > 0);
my.pan -= mickey.x;
camera.pan = my.pan;
camera.tilt -= mickey.y;
c_move(me,input_vec,nullvector,GLIDE);
c_move(me,nullvector,vector(0,0,(Vz - 10) * time),0);
if(trace_hit)
{
jump_able = 1;
}
vec_set(camera.x,my.x);
camera.z += 10;
wait(1);
}
}



Posted By: mpdeveloper_B

Re: Player 1st-Person with Gravity - 02/14/08 22:51

you forgot c_setminmax(me); to make sure that the model lands on its feet
Posted By: kasimir

Re: Player 1st-Person with Gravity - 02/16/08 15:19

you should also use vec_normalize or the player is faster if you walk forward while strafing than just walk forward... (without strafing)
...
input_vec.x = (key_w - key_s);
input_vec.y = (key_a - key_d);
vec_normalize(input_vec,time * 5);
...
© 2024 lite-C Forums