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);

}

}




I want to Entertain you...