]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add primitive air friction to make testing a bit easier
authorMario <zacjardine@y7mail.com>
Sat, 15 Sep 2018 01:00:35 +0000 (11:00 +1000)
committerMario <zacjardine@y7mail.com>
Sat, 15 Sep 2018 01:00:35 +0000 (11:00 +1000)
qcsrc/ecs/systems/physics.qc

index 954c35fe555ea3e02a2e4e4a9e0d6ed8290ec314..af843a9df415648fc7c4d7b03dd18697fe7eb676 100644 (file)
@@ -532,6 +532,7 @@ void sys_phys_update(entity this, float dt)
        float jumpvel = this.com_phys_jumpvel;
        float bounce = this.com_phys_bounce;
        float friction = this.com_phys_friction;
+       float airfriction = this.com_phys_friction * 0.5;
        float gravity = this.com_phys_gravity.z;
        bool noclip = this.com_phys_noclip;
        if (noclip)
@@ -567,6 +568,15 @@ void sys_phys_update(entity this, float dt)
                                vel = slide + push;
                        }
                }
+               else
+               {
+                       float oldz = vel.z;
+                       vector slide = vel;
+                       vector push = vel - slide;
+                       slide *= 1 - airfriction * dt;
+                       vel = slide + push;
+                       vel.z = oldz;
+               }
                vector step = vel * dt;
                bool pass = false;
                bool foundground = false;                  // assume until proven otherwise