problems with wdl player jumping

Posted By: CrYzZeR

problems with wdl player jumping - 07/26/10 21:23

English:

Hello Guys.

I have a player wdl Code from the Aum (thanks Georg) and have it a little bit modified. but the Problem is, when i jump the player keeps exactly the jump height. Thats a problem when I jump over a hole for example, because the player falls into the hole and stopps when the coded jump height is reached. Sry for my bad english I hope you know what i mean. Can you help me? The code is down my post.

Deutsch:

Hallo Gamestudio User!

Ich habe hier einen Player code von dem AUM Magazine (danke georg)
ich habe ihn leicht modifiziert und er funktioniert ganz gut soweit.
Nur habe ich ein Problem:
Wenn ich springe, wird die exakte Sprunghöhe eingehalten. Das ist aber ein Problem wenn ich zum Beispiel über ein Loch springen will. Weil der Player dann soweit hineinfällt, bis die maximale Sprunghöhe wieder erreicht ist. Ich möchte aber, dass er ganz normal drüberspringen kann.

Ich habe mir überlegt, dass ich irgendwie von einer anderen Position aus die maximiale Sprunghöhe festlegen sollte. Diese Position müsste ja aber dann undter meinen wegen usw. gehen wo ich später mit meinem Player entlanglaufe. Oder habt ihr andere Ideen?

Bin noch kein Proficoder also wenns geht bitte etwas ausführlicher ( ist nicht böse gemeint wink )

Danke schonmal für eure Aufmerksamkeit grin


E: Heres the code:
DE: Hier ist der Code:

Click to reveal..

action players_code

{


var anim_percentage; // animation percentage

var jump_percentage; // animation percentage for jumping

var movement_speed; // player's movement speed

var distance_to_ground; // the distance between player's origin and the ground

var jump_height;

var reached_height;

player = my; // I'm the player

while (1)

{
camera.x = player.x - 100;

camera.y = player.y - 400; // play with 400

camera.z = player.z + 120; // play with 120

camera.pan = player.pan + 50; // play with 90
vec_set (temp.x, my.x); // copy player's position to temp

temp.z -= 5000; // set temp.z 5000 quants below player's origin

distance_to_ground = c_trace (my.x, temp.x, ignore_me | use_box);

movement_speed.x = 8* (key_cur - key_cul) * time;

movement_speed.y = 0; // don't move sideways

movement_speed.z = - (distance_to_ground - 5); // 17 = experimental value

movement_speed.z = max (-40 * time, movement_speed.z); // 35 = falling speed

if ((key_space == on) && (reached_height == 0))

{

jump_height = min(50, jump_height + 8 * time); // 40 sets the height, 5 sets the ascending speed

if (jump_height == 50) // reached the maximum height? Then start descending!

{

reached_height = 1;

jump_height = max(0, jump_height - 8 * time); // 5 sets the falling speed

}

}

else // space isn't pressed anymore?

{

jump_height = max(0, jump_height - 3 * time); // use a smaller falling speed (3) for (potential) smaller jumps

if ((jump_height == 0) && (key_space == off)) // the player has touched the ground?

{

reached_height = 0; // then allow it to jump again

}

}

movement_speed.z = - (distance_to_ground - 0) + jump_height; // 17 = experimental value

movement_speed.z = max (-35 * time, movement_speed.z); // 35 = falling speed

c_move (my, movement_speed.x, nullvector, glide); // move the player

if (jump_height == 0) // the player isn't jumping?

{

if ((key_cur == off) && (key_cul == off)) // the player isn't moving?

{

ent_animate(my, "stand", anim_percentage, anm_cycle); // play the "stand" animation

}

else // the player is moving?

{

ent_animate(my, "walk", anim_percentage, anm_cycle); // play the "walk" animation

}

anim_percentage += 5 * time; // 5 = animation speed

jump_percentage = 0; // always start jumping with the first frame

}

else // the player is jumping

{

jump_percentage += 5 * time; // 5 = jump animation speed

ent_animate(my, "jump", jump_percentage, anm_cycle); // play the "jump" animation




}

wait (1);

}

}


Posted By: CrYzZeR

Re: problems with wdl player jumping - 07/28/10 16:39

Hmm, or does anybody have a free to use Jump n run wdl code who don`t have this Problem? It would be very very nice when anybody can give me someone.

Greets
Posted By: Arrovs

Re: problems with wdl player jumping - 07/29/10 13:31

You should give vertical power impulse.
And constant downforce if height over earth is bigger then 0.

while(blabla)
{
result=trace(my.pos,vector(my.x,my.y,my.z-2000));
if(result>1){gravity.z-=1*time_step;}
else{gravity.z=0;}
//jump power
if(result=<0&&key_space==1)
{gravity.z=10;}
c_move(my,standart_movement,gravity,blabla);
wait(1);
}

I wrote it very fast so here is main idea.
But it works.
If result dont work well with 0 then use 1.
Posted By: CrYzZeR

Re: problems with wdl player jumping - 08/11/10 09:41

thank you. I will try it.
© 2024 lite-C Forums