mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-12 16:58:39 +00:00
Fix formula used for acceleration (#12353)
This commit is contained in:
parent
11905a6db6
commit
1317cd12d7
7 changed files with 29 additions and 16 deletions
|
@ -195,21 +195,24 @@ void ClientEnvironment::step(float dtime)
|
|||
lplayer->applyControl(dtime_part, this);
|
||||
|
||||
// Apply physics
|
||||
lplayer->gravity = 0;
|
||||
if (!free_move) {
|
||||
// Gravity
|
||||
v3f speed = lplayer->getSpeed();
|
||||
if (!is_climbing && !lplayer->in_liquid)
|
||||
speed.Y -= lplayer->movement_gravity *
|
||||
lplayer->physics_override.gravity * dtime_part * 2.0f;
|
||||
// HACK the factor 2 for gravity is arbitrary and should be removed eventually
|
||||
lplayer->gravity = 2 * lplayer->movement_gravity * lplayer->physics_override.gravity;
|
||||
|
||||
// Liquid floating / sinking
|
||||
if (!is_climbing && lplayer->in_liquid &&
|
||||
!lplayer->swimming_vertical &&
|
||||
!lplayer->swimming_pitch)
|
||||
speed.Y -= lplayer->movement_liquid_sink * dtime_part * 2.0f;
|
||||
// HACK the factor 2 for gravity is arbitrary and should be removed eventually
|
||||
lplayer->gravity = 2 * lplayer->movement_liquid_sink;
|
||||
|
||||
// Movement resistance
|
||||
if (lplayer->move_resistance > 0) {
|
||||
v3f speed = lplayer->getSpeed();
|
||||
|
||||
// How much the node's move_resistance blocks movement, ranges
|
||||
// between 0 and 1. Should match the scale at which liquid_viscosity
|
||||
// increase affects other liquid attributes.
|
||||
|
@ -232,15 +235,16 @@ void ClientEnvironment::step(float dtime)
|
|||
(1 - resistance_factor);
|
||||
v3f d = d_wanted.normalize() * (dl * dtime_part * 100.0f);
|
||||
speed += d;
|
||||
}
|
||||
|
||||
lplayer->setSpeed(speed);
|
||||
lplayer->setSpeed(speed);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Move the lplayer.
|
||||
This also does collision detection.
|
||||
*/
|
||||
|
||||
lplayer->move(dtime_part, this, position_max_increment,
|
||||
&player_collisions);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue