diff --git a/source/src/entity.h b/source/src/entity.h index 32a816d4..e5fed23f 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -101,7 +101,7 @@ public: int timeinair; // used for fake gravity float radius, eyeheight, maxeyeheight, aboveeye; // bounding box size bool inwater; - bool onfloor, onladder, jumpnext, crouching, trycrouch, cancollide, stuck; + bool onfloor, onladder, jumpnext, crouching, crouchedinair, trycrouch, cancollide, stuck; int lastjump; int lastsplash; char move, strafe; @@ -109,7 +109,7 @@ public: float eyeheightvel; physent() : o(0, 0, 0), deltapos(0, 0, 0), newpos(0, 0, 0), yaw(270), pitch(0), roll(0), pitchvel(0), - crouching(false), trycrouch(false), cancollide(true), stuck(false), lastjump(0), lastsplash(0), state(CS_ALIVE) + crouching(false), crouchedinair(false), trycrouch(false), cancollide(true), stuck(false), lastjump(0), lastsplash(0), state(CS_ALIVE) { reset(); } @@ -127,7 +127,7 @@ public: vel.x = vel.y = vel.z = eyeheightvel = 0.0f; move = strafe = 0; timeinair = lastjump = lastsplash = 0; - onfloor = onladder = inwater = jumpnext = crouching = trycrouch = stuck = false; + onfloor = onladder = inwater = jumpnext = crouching = crouchedinair = trycrouch = stuck = false; } virtual void oncollision() {} diff --git a/source/src/physics.cpp b/source/src/physics.cpp index 2ac2a669..7ce8dae2 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -444,12 +444,15 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime) pl->lastjump = lastmillis; } pl->timeinair = 0; + pl->crouchedinair = false; } else { pl->timeinair += curtime; - if (pl->trycrouch && !pl->crouching) pl->vel.z += 0.8f; - if (!pl->trycrouch && pl->crouching) pl->vel.z -= 0.8f; + if (pl->trycrouch && !pl->crouching && !pl->crouchedinair) { + pl->vel.z += 0.6f; + pl->crouchedinair = true; + } } }