]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Improve physics in water when frozen
authorterencehill <piuntn@gmail.com>
Sun, 24 May 2020 09:18:23 +0000 (11:18 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 24 May 2020 09:18:23 +0000 (11:18 +0200)
qcsrc/ecs/systems/physics.qc

index fb0781e49e527391914ce6bc924e29eab822b2e4..75657c90f268c6f9248377114df942c96fbf1674 100644 (file)
@@ -220,8 +220,10 @@ void sys_phys_simulate(entity this, float dt)
        if (this.com_phys_water) {
                if (PHYS_FROZEN(this))
                {
-                       if(this.waterlevel >= WATERLEVEL_SUBMERGED)
+                       if(this.waterlevel >= WATERLEVEL_SUBMERGED && this.velocity.z >= -70) // don't change the speed too abruptally
                                wishvel = '0 0 160'; // resurface
+                       else if(this.waterlevel >= WATERLEVEL_SWIMMING && this.velocity.z > 0)
+                               wishvel = eZ * 1.3 * min(this.velocity.z, 160); // resurface a bit more above the surface
                }
                else
                {