From 4fc1ca54cb5a8f21c04c5e3f14f7c1e16101f455 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 15 Sep 2018 11:00:35 +1000 Subject: [PATCH] Add primitive air friction to make testing a bit easier --- qcsrc/ecs/systems/physics.qc | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 -- 2.39.2