From: Mario Date: Sat, 15 Sep 2018 01:00:35 +0000 (+1000) Subject: Add primitive air friction to make testing a bit easier X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4fc1ca54cb5a8f21c04c5e3f14f7c1e16101f455;p=xonotic%2Fxonotic-data.pk3dir.git Add primitive air friction to make testing a bit easier --- diff --git a/qcsrc/ecs/systems/physics.qc b/qcsrc/ecs/systems/physics.qc index 954c35fe55..af843a9df4 100644 --- a/qcsrc/ecs/systems/physics.qc +++ b/qcsrc/ecs/systems/physics.qc @@ -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