mirror of
https://github.com/minetest/minetest.git
synced 2024-11-30 11:33:44 +01:00
Fix "bouncy" blocks
Before players "bounced" too high. Now, while still allowing to bounce, higher speed bounces are throttled.
This commit is contained in:
parent
868a1a5c13
commit
060e56b24c
@ -319,25 +319,15 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
|
|||||||
/*
|
/*
|
||||||
Report collisions
|
Report collisions
|
||||||
*/
|
*/
|
||||||
bool bouncy_jump = false;
|
|
||||||
// Dont report if flying
|
// Dont report if flying
|
||||||
if(collision_info && !(g_settings->getBool("free_move") && fly_allowed)) {
|
if(collision_info && !(g_settings->getBool("free_move") && fly_allowed)) {
|
||||||
for(size_t i=0; i<result.collisions.size(); i++) {
|
for(size_t i=0; i<result.collisions.size(); i++) {
|
||||||
const CollisionInfo &info = result.collisions[i];
|
const CollisionInfo &info = result.collisions[i];
|
||||||
collision_info->push_back(info);
|
collision_info->push_back(info);
|
||||||
if(info.new_speed.Y - info.old_speed.Y > 0.1*BS &&
|
|
||||||
info.bouncy)
|
|
||||||
bouncy_jump = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bouncy_jump && control.jump){
|
|
||||||
m_speed.Y += movement_speed_jump*BS;
|
|
||||||
touching_ground = false;
|
|
||||||
MtEvent *e = new SimpleTriggerEvent("PlayerJump");
|
|
||||||
m_gamedef->event()->put(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!touching_ground_was && touching_ground){
|
if(!touching_ground_was && touching_ground){
|
||||||
MtEvent *e = new SimpleTriggerEvent("PlayerRegainGround");
|
MtEvent *e = new SimpleTriggerEvent("PlayerRegainGround");
|
||||||
m_gamedef->event()->put(e);
|
m_gamedef->event()->put(e);
|
||||||
@ -371,6 +361,19 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
|
|||||||
m_can_jump = touching_ground && !in_liquid;
|
m_can_jump = touching_ground && !in_liquid;
|
||||||
if(itemgroup_get(f.groups, "disable_jump"))
|
if(itemgroup_get(f.groups, "disable_jump"))
|
||||||
m_can_jump = false;
|
m_can_jump = false;
|
||||||
|
// Jump key pressed while jumping off from a bouncy block
|
||||||
|
if (m_can_jump && control.jump && itemgroup_get(f.groups, "bouncy") &&
|
||||||
|
m_speed.Y >= -0.5 * BS) {
|
||||||
|
float jumpspeed = movement_speed_jump * physics_override_jump;
|
||||||
|
if (m_speed.Y > 1) {
|
||||||
|
// Reduce boost when speed already is high
|
||||||
|
m_speed.Y += jumpspeed / (1 + (m_speed.Y / 16 ));
|
||||||
|
} else {
|
||||||
|
m_speed.Y += jumpspeed;
|
||||||
|
}
|
||||||
|
setSpeed(m_speed);
|
||||||
|
m_can_jump = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d)
|
void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d)
|
||||||
|
Loading…
Reference in New Issue
Block a user