I'm trying to implement weapon sway where the rotation of the weapon lags behind the camera's rotation, think Half-Life 2 or Dusk for example. The sprite-based weapon sway in doom mods is position-based for obvious reasons. However, I have looked at the code for Disdain, and the 3d weapons lag behind based on their positions too, and looks like there doesn't seem to be a way to rotate 3d weapons at runtime outside of their MODELDEF definitions.
However, after looking through the ZDoom wiki, I have come across these 2 virtual functions: ModifyBobLayer3D and ModifyBobPivotLayer3D. [wiki]https://zdoom.org/wiki/Weapon_virtual_functions[/wiki]
For the first function, there's only info on its arguments (which contains rotation), and the second function has not been documented at all. I have also looked through the GitHub repository, but could not find any info or examples on using these functions in code.
EDIT: I figured it out on my own. Here's how to use them:
//--------------------------------------------------------------
//Inside your Weapon class:
override Vector3, Vector3 ModifyBobLayer3D(Vector3 Translation, Vector3 Rotation, int layer, double ticfrac) {
//modify the values of Translation and Rotation here;
return Translation, Rotation;
}
[SOLVED] Rotation-Based 3D Weapon Sway | Undocumented Functions
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
-
gzedbone
- Posts: 1
- Joined: Tue Apr 01, 2025 2:46 pm