afinaments

This commit is contained in:
2026-04-11 19:05:29 +02:00
parent 72741896c1
commit c1764ba0d8
4 changed files with 28 additions and 11 deletions

View File

@@ -204,11 +204,22 @@ void Player::updateVelocity(float delta_time) {
}
} else {
if (target != 0.0F) {
// Reset al cambiar de dirección: un giro breve también para en seco.
if (vx_ != 0.0F && ((target > 0.0F) != (vx_ > 0.0F))) {
walk_time_ = 0.0F;
}
vx_ = target;
walk_time_ += delta_time;
} else if (walk_time_ < WALK_INERTIA_THRESHOLD) {
// Tap corto: parada seca, sin inercia (permite pasos finos).
vx_ = 0.0F;
walk_time_ = 0.0F;
} else if (vx_ > 0.0F) {
vx_ = std::max(vx_ - STEP, 0.0F);
if (vx_ == 0.0F) { walk_time_ = 0.0F; }
} else if (vx_ < 0.0F) {
vx_ = std::min(vx_ + STEP, 0.0F);
if (vx_ == 0.0F) { walk_time_ = 0.0F; }
}
}
}
@@ -551,6 +562,7 @@ void Player::transitionToState(State state) {
case State::ON_AIR:
last_grounded_position_ = static_cast<int>(y_);
current_carrier_ = nullptr; // Perder carry al despegar
walk_time_ = 0.0F; // Al aterrizar volverá a contar desde 0
break;
}
}