[Fix] Issue with gravity sucking half the player into the ground.
This commit is contained in:
parent
c5a722b047
commit
5d045e2fa7
@ -1,7 +1,5 @@
|
||||
#include <cmath>
|
||||
#include "bettola/game/player_base.h"
|
||||
#include "bettola/network/player_input_message.h"
|
||||
#include "game/player.h"
|
||||
|
||||
/* Use a static variable for ID generation across all player types. */
|
||||
static unsigned int next_player_id = 1;
|
||||
@ -23,8 +21,9 @@ void PlayerBase::update(double dt) {
|
||||
}
|
||||
|
||||
void PlayerBase::apply_gravity_and_collision(float terrain_height) {
|
||||
if(_position.y < terrain_height) {
|
||||
_position.y = terrain_height;
|
||||
const float player_height_offset = 0.5f; /* Half the player model height. */
|
||||
if(_position.y < terrain_height + player_height_offset) {
|
||||
_position.y = terrain_height + player_height_offset;
|
||||
_velocity.y = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user