Weapon model sway techniques
Weapon model sway techniques
I'm trying to create an effect similar to the one implemented in TF2: https://www.youtube.com/watch?v=4wPAzutIVpc
And other titles as well: https://www.youtube.com/watch?v=kjVSLsz8dCs
Note that this is not player model bobbing, it's just a subtle effect on the camera and the model itself, slowly reaching the new view target. I could not find any documentation on this topic around the internet and i suspect there's some heavy math behind this and it would be nice if someone here has any idea on how to implement that kind of code. Or, at least, can give me some good directions on the topic. Thanks!
And other titles as well: https://www.youtube.com/watch?v=kjVSLsz8dCs
Note that this is not player model bobbing, it's just a subtle effect on the camera and the model itself, slowly reaching the new view target. I could not find any documentation on this topic around the internet and i suspect there's some heavy math behind this and it would be nice if someone here has any idea on how to implement that kind of code. Or, at least, can give me some good directions on the topic. Thanks!
Re: Weapon model sway techniques
darkplaces has something like that
look in the engine source, or the xonotic quakeC source, might have it...
look in the engine source, or the xonotic quakeC source, might have it...
Re: Weapon model sway techniques
Darkplaces has normal bobbing, applied to the camera, but nothing on weapon model sway.
-
- Posts: 14
- Joined: Sun Oct 19, 2014 2:37 am
Re: Weapon model sway techniques
You could make this effect in qc but Darkplaces already has this built into the engine using the cvars cl_leanmodel and cl_followmodel. For more details on these and a few other cvars that let you customize this movement type in console "apropos cl_leanmodel" or "apropos cl_followmodel". It is highly customizable to get the effect you desire. You can even use negative values to change the weapon models react to input movements of the player. No need for qc changes.
Re: Weapon model sway techniques
Eukos implemented this for OpenKatana sometime ago, might be worth digging through our code to see how it was done.
https://github.com/OldTimes-Software/Ka ... iew.c#L572
I believe it's all within a function called View_ModelDrift.
https://github.com/OldTimes-Software/Ka ... iew.c#L572
I believe it's all within a function called View_ModelDrift.
Last edited by hogsy on Sat Nov 14, 2015 2:53 pm, edited 1 time in total.
Re: Weapon model sway techniques
Thanks a lot for the info, guys. The OpenKatana code was very instructive.
Re: Weapon model sway techniques
Implementing a subtle https://en.wikipedia.org/wiki/Lissajous_curve for the bobbing was the way to go. And i was inspired by this video to create the "weapon weight" effect:
https://www.youtube.com/watch?v=ay2SMb9-nEE
https://www.youtube.com/watch?v=ay2SMb9-nEE
Re: Weapon model sway techniques
It's for camera bob, there's no influence on the weapon model based on player input.
Re: Weapon model sway techniques
I have added something like this in Qrack, v_viewmodeldrift # all it does is delay the time the gun moves from when the player changes angles. I'll post some code later but im sure i thought i looked at darkplaces to learn about the effect.
Re: Weapon model sway techniques
JasonX: Get the latest version of Engoo. I'm using version 2.77, and in "Options —> View Options" there are options not only for weapon bobbing, but also for weapon following, weapon leaning, weapon drawing and fall bobbing. The "weapon leaning" option is what you're after.
The latest versions of Engoo did add a lot of features everywhere.
The latest versions of Engoo did add a lot of features everywhere.
Re: Weapon model sway techniques
Code: Select all
/*
======
View_ModelDrift -- Eukos from OpenKatana
Adds a delay to the view model (such as a weapon) in the players view.
======
*/
void View_ModelDrift(vec3_t vOrigin,vec3_t vAngles,vec3_t vOldAngles)
{
int i;
float fScale,fSpeed,fDifference;
static vec3_t svLastFacing;
vec3_t vForward, vRight,vUp, vDifference;
AngleVectors(vAngles,vForward,vRight,vUp);
if (host_frametime != 0.0f)
{
VectorSubtract(vForward,svLastFacing,vDifference);
fSpeed = 6.0f;
fDifference = VectorLength(vDifference);
if ((fDifference > cl_gun_drift.value ))
fSpeed *= fScale = fDifference/cl_gun_drift.value;
for (i = 0; i < 3; i++)
svLastFacing[i] += vDifference[i]*(fSpeed*host_frametime);
VectorNormalize(svLastFacing);
for (i = 0; i < 3; i++)
{
vOrigin[i] += (vDifference[i]*-1.0f)*5.0f;
vAngles[ROLL] += vDifference[YAW];
}
}
}