Fixed 'onground' && turning-off flight mode if onground
This commit is contained in:
parent
30c2d9889e
commit
07e2fe8b3b
@ -11,6 +11,7 @@ PhysicsSolver::PhysicsSolver(vec3 gravity) : gravity(gravity) {
|
||||
}
|
||||
|
||||
void PhysicsSolver::step(Chunks* chunks, Hitbox* hitbox, float delta, unsigned substeps, bool shifting, float gravityScale) {
|
||||
hitbox->grounded = false;
|
||||
for (unsigned i = 0; i < substeps; i++){
|
||||
float dt = delta / (float)substeps;
|
||||
float linear_damping = hitbox->linear_damping;
|
||||
@ -75,7 +76,6 @@ void PhysicsSolver::step(Chunks* chunks, Hitbox* hitbox, float delta, unsigned s
|
||||
}
|
||||
}
|
||||
|
||||
hitbox->grounded = false;
|
||||
if (vel.y < 0.0){
|
||||
for (int x = floor(pos.x-half.x+E); x <= floor(pos.x+half.x-E); x++){
|
||||
bool broken = false;
|
||||
|
||||
@ -117,6 +117,8 @@ void update_controls(PhysicsSolver* physics,
|
||||
camera->position.y = hitbox->position.y + 0.5f;
|
||||
camera->position.z = hitbox->position.z;
|
||||
|
||||
if (player->flight && hitbox->grounded)
|
||||
player->flight = false;
|
||||
// Camera shaking
|
||||
player->interpVel = player->interpVel * (1.0f - delta * 5) + hitbox->velocity * delta * 0.1f;
|
||||
if (hitbox->grounded && player->interpVel.y < 0.0f){
|
||||
@ -132,6 +134,10 @@ void update_controls(PhysicsSolver* physics,
|
||||
|
||||
if (Events::jpressed(GLFW_KEY_F)){
|
||||
player->flight = !player->flight;
|
||||
if (player->flight){
|
||||
hitbox->velocity.y += 1;
|
||||
hitbox->grounded = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Field of view manipulations
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user