2 registered members (AndrewAMD, dpn),
1,328
guests, and 10
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Will do free coding - if contented donations are welcome
[Re: Scorpion]
#281634
07/27/09 21:50
07/27/09 21:50
|
Joined: Feb 2009
Posts: 3,207 Germany, Magdeburg
Rei_Ayanami
Expert
|
Expert
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
|
Hello ! Okay, I use the System from Grimbers FPS Tutorial, for the stairs and things like this. If I want to go a little bevel(sorry i don´t know what "schräge" is in english) my player moves soooo slow, and if i want to go in 90° angle to the "bevel" my player doesn´t move at all -.- . Here is the part from my code which do this things :
fall_distance = c_trace(player.x, vector(my.x, my.y, my.z - 500), IGNORE_ME | IGNORE_YOU | IGNORE_SPRITES | IGNORE_MODELS | USE_BOX);
if(fall_distance > 64 && sign(fall_distance) != -1 && jumping == 0)
{
falling = 1; //falle
}
else
{
if(fall_distance < 64 && falling == 0 && jumping == 0)
{
player_move.z = -fall_distance * time_step;
}
}
if(fall_distance > 32 && jumping == 0)
{
falling = 1;
if(player_move.z > -20 * time_step)
{
player_move.z -= 0.5 * time_step;
}
}
else falling = 0;
c_move(me, player_move, nullvector, GLIDE | IGNORE_PASSABLE); //bewegt den Spieler, relativ zu seinem Pan, Tilt und Roll winkel und lässt in an Wänden etx gleiten und ignoriert objekte die Passabel sind
Please tell me what is wrong
|
|
|
Re: Will do free coding - if contented donations are welcome
[Re: Scorpion]
#281649
07/28/09 00:02
07/28/09 00:02
|
Joined: Feb 2005
Posts: 197 Indiana
darkraven1
Member
|
Member
Joined: Feb 2005
Posts: 197
Indiana
|
Hey saw your post and wanted to say hey We are looking to get a team together and sounds like we could use someone like you for our Project. We are looking to be picked up by Ubi so this a serious project. I would like to talk to you more about it But I am unable to PM you.
Last edited by darkraven1; 07/28/09 00:07.
|
|
|
Re: Will do free coding - if contented donations are welcome
[Re: Scorpion]
#281755
07/28/09 13:49
07/28/09 13:49
|
Joined: Jul 2009
Posts: 11
Saruniks
Newbie
|
Newbie
Joined: Jul 2009
Posts: 11
|
oh sorry
Last edited by Saruniks; 07/28/09 13:59.
|
|
|
Re: Will do free coding - if contented donations are welcome
[Re: Rei_Ayanami]
#281819
07/28/09 20:31
07/28/09 20:31
|
Joined: Jan 2007
Posts: 1,619 Germany
Scorpion
OP
Serious User
|
OP
Serious User
Joined: Jan 2007
Posts: 1,619
Germany
|
okay, here is a pretty solid player function, that let you walk stairs fluidly, jump and well...walk. I put the defaults so that they more or less fit the standard scale of 1 quant = 1 inch. Maybe he jumps a little too high or falls too slow, or I don't know. Just play with the default settings. The only problem that occurs with it is a little jitter, when moving slopes down. You won't probably notice it. IF you need it fixed, just use a variation of how I fixed the stair climbing issue and make, that gravity has no influence in that case (= put it on the ground). I'm talking too much. Here's the code:
action controller(){
//parameters to change
int moveSpeed = 30;//inch in one ticks...thats how fast world recordlers run
float stopFactor = 0.7;//the velocity of the player gets multiplied with that every frame
int maxStepHeight = 16;//name says all. 16 inches should be even too high
int groundDist = 1;//don't make it hard for the collision system
float gravity = 2;//in a vacuum it would be ca. 24 inch/tick^2 (9.81 m/s^2)
float heighCorrectionFactor = 0.9;//for climbing stairs and slopes
int jumpForce = 10;//how good can you jump?
move_min_z = 0.707;//stairclimping by c_move not over 45° of the elipsiod
//used by player function
VECTOR moveDir;
VECTOR movement;
float fallDist;
int onGround = 0;
VECTOR vel;
vec_zero(moveDir);
vec_zero(movement);
vec_zero(vel);
player=me;
wait(1);
c_setminmax(me);
while(1){
moveDir.x = (key_w-key_s); //get direction
moveDir.y = (key_a-key_d);
my.pan -= 2*mouse_force.x;
camera.tilt = clamp(camera.tilt + 2*mouse_force.y,-90,90);
fallDist = c_trace(player.x, vector(my.x, my.y, my.z - 500), IGNORE_ME | IGNORE_YOU | IGNORE_SPRITES | IGNORE_MODELS | USE_BOX);
//check for ground contact
if(fallDist <= groundDist)
onGround = 1;
else
onGround = 0;
//help me with stairs
if(moveDir.x || moveDir.y){//moving?
//trace down where you're moving to
VECTOR stairTracePos;
vec_set(stairTracePos, moveDir);
vec_normalize(stairTracePos, my.max_x);
vec_rotate(stairTracePos, my.pan);
vec_add(stairTracePos, vector(my.x, my.y, my.z+my.min_z));
result = c_trace(vector(stairTracePos.x, stairTracePos.y, stairTracePos.z+maxStepHeight), stairTracePos, IGNORE_ME|IGNORE_PASSABLE|IGNORE_SPRITES|IGNORE_MODELS);
if(trace_hit){
my.z += (maxStepHeight-result+groundDist)*heighCorrectionFactor*time_step;
onGround = 1;
}
}
//gravitation
if(!onGround){
vel.z -= gravity*time_step;
}
else
vel.z = 0;
//jumping
if(onGround && key_space){
vel.z = jumpForce;
}
//xy-movement
if(moveDir.x)
vel.x = 15*moveDir.x;
else
vel.x *= 1.0-(1.0-stopFactor)*time_step;//anti propotional relation
if(moveDir.y)
vel.y = 15*moveDir.y;
else
vel.y *= 1.0-(1.0-stopFactor)*time_step;//anti propotional relation
movement.x = vel.x*time_step;
movement.y = vel.y*time_step;
c_move(me, nullvector, vector(0,0, vel.z), GLIDE|IGNORE_PASSABLE);//if we jump, we might crash against the ceiling
c_move(me, movement, nullvector, GLIDE|IGNORE_PASSABLE);//now move on xy
vec_set(camera.x, my.x);
camera.z += 32.5;
camera.pan = my.pan;
wait(1);
}
}
|
|
|
|