Advertisement

Jumping in a FPS question

Started by January 25, 2003 02:52 PM
12 comments, last by UponTheEnd 22 years, 1 month ago
real simple:

have a y velocity variable, and when you press space or whatever you will press to jump it will add like 10 to the velocity. every frame y+=yvelocity, and yvelocity-=0.5 or some other number, play with it until it feels good.
That will give the realistic looking curve that occurs when you jump or when you throw an object.
That's fysics/psysics math.

You can be learned that in school.
Ask a teacher.

Something with the mass and gravity.

The earth gravity is 9.82

Than a certain jump force/speed/power.

y or z up/down?

The mass = the weight in kilograms * 9.82
The mass in Newton.

I know when something falls it's speed increases/grows with something.


#define GRAVITY 9.82
#define JUMP_FORCE 8.5
#define MASS 687.4
// for example
or

const double gravity = 9.82
const double jump_force = 8.5
const float mass = 687.4
// for example


enum
{
_upwards,
_downwards
};

short up_or_down;

float x, y, z;
// your position


float delta_x, delta_y, delta_z;
float jump_force_delta;

switch (up_or_down)
{
case upwards:
if (jump_up_for_the_first_time)
{
delta_y = jump_force;
jump_force_delta =
}
delta_y -= jump_force_delta;
y -= delta_y;
break;
case downwards:
y += delta_y;
break;
default:
break;
}


I'm not sure at all.
I can be wrong, but I do my best to help, it's just fun.
A little advice, try and figure it out with paper and pencil, you are thinking better then.
But I can look it up in a source code of Marathon 2 (2.4mb).

[edited by - programering on January 30, 2003 8:46:23 AM]
Advertisement

void accelerate_player(
short monster_index,
world_distance vertical_velocity,
angle direction,
world_distance velocity)
{
short player_index= monster_index_to_player_index(monster_index);
struct player_data *player= get_player_data(player_index);
struct physics_variables *variables= &player->variables;
struct physics_constants *constants= get_physics_constants_for_model(static_world->physics_model, 0);
fixed new_external_velocity= WORLD_TO_FIXED(velocity);

variables->external_velocity.k+= WORLD_TO_FIXED(vertical_velocity);

// here maybe
variables->external_velocity.k= PIN(variables->external_velocity.k, -constants->terminal_velocity, constants->terminal_velocity);


variables->external_velocity.i+= (cosine_table[direction]*velocity)>>(TRIG_SHIFT+WORLD_FRACTIONAL_BITS-FIXED_FRACTIONAL_BITS);
variables->external_velocity.j+= (sine_table[direction]*velocity)>>(TRIG_SHIFT+WORLD_FRACTIONAL_BITS-FIXED_FRACTIONAL_BITS);

return;
}



Anton Karlsson


Klingis Entertainment


Games with silly humor
About the bullet : When the guy shoots the bullet dont just consider where the guy is looking but also consider if the guy is moving sideways or not. If the guy is moving sideways, the bullet should be moving sideways with the same speed.

This topic is closed to new replies.

Advertisement