Improve physics in water when frozen 817/head
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 fb0781e..75657c9 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
                {