From 12e19922e63888d6c029ad879d87189fe5258911 Mon Sep 17 00:00:00 2001 From: terencehill Date: Sat, 27 Feb 2016 16:48:32 +0100 Subject: [PATCH] cl_bobmodel: always restart the effect in the same way --- qcsrc/client/view.qc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 2c6282152..76b648e1f 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -236,9 +236,8 @@ void viewmodel_animate(entity this) { // calculate for swinging gun model // the gun bobs when running on the ground, but doesn't bob when you're in the air. - float bspeed; static float bobmodel_scale = 0; - float s = time * autocvar_cl_bobmodel_speed; + static float time_ofs = 0; // makes the effect always restart in the same way if (clonground) { if (time - hitgroundtime > 0.05) @@ -246,15 +245,18 @@ void viewmodel_animate(entity this) } else bobmodel_scale = max(0, bobmodel_scale - frametime * 5); - if(bobmodel_scale) + if(bobmodel_scale && xyspeed) { - bspeed = xyspeed * 0.01 * autocvar_cl_viewmodel_scale * bobmodel_scale; + float bspeed = xyspeed * 0.01 * autocvar_cl_viewmodel_scale * bobmodel_scale; + float s = (time - time_ofs) * autocvar_cl_bobmodel_speed; vector gunorg = '0 0 0'; gunorg.y = bspeed * autocvar_cl_bobmodel_side * sin(s); gunorg.z = bspeed * autocvar_cl_bobmodel_up * cos(s * 2); this.origin += gunorg; } + else + time_ofs = time; } } -- 2.39.2