Bobbing functionality in ZScript?
Moderator: GZDoom Developers
- nazakomu
- Posts: 131
- Joined: Wed Nov 30, 2016 12:51 am
- Graphics Processor: nVidia with Vulkan support
Bobbing functionality in ZScript?
This may sound completely redundant but I'd be thankful if someone wanted to implement it.
Basically, if anyone has ever paid close attention to the way bobbing works in a Build game (in this instance, Duke Nukem 3D was my reference), there are two things to notice. When the player begins to move - the bobbing starts slow but then speeds up and the X/Y movement intensify until the player has reached the maximum speed.
This gave me an idea for a property (Or a function? Considering there isn't anything but custom properties as of right now) to be implemented into ZScript where the bob speed is adaptive to the speed that the player is moving at. Or make it completely adjustable (intensity, adaptive). The "adaptive" could be a 'true' or 'false' and if it is desired to be true, then it will disregard the intensity parameter and instead use an "adaptive-to-player's-speed" bobbing speed.
Considering that the bobbing speed property is static, this is the only reason that I am requesting this otherwise I wouldn't be. There is probably an entirely different way of implementing something like this, but tl;dr: implement a similar or exact type of bobbing system like Build's? I hope you don't despise me for the idea!
Basically, if anyone has ever paid close attention to the way bobbing works in a Build game (in this instance, Duke Nukem 3D was my reference), there are two things to notice. When the player begins to move - the bobbing starts slow but then speeds up and the X/Y movement intensify until the player has reached the maximum speed.
This gave me an idea for a property (Or a function? Considering there isn't anything but custom properties as of right now) to be implemented into ZScript where the bob speed is adaptive to the speed that the player is moving at. Or make it completely adjustable (intensity, adaptive). The "adaptive" could be a 'true' or 'false' and if it is desired to be true, then it will disregard the intensity parameter and instead use an "adaptive-to-player's-speed" bobbing speed.
Considering that the bobbing speed property is static, this is the only reason that I am requesting this otherwise I wouldn't be. There is probably an entirely different way of implementing something like this, but tl;dr: implement a similar or exact type of bobbing system like Build's? I hope you don't despise me for the idea!
- wildweasel
- Posts: 21706
- Joined: Tue Jul 15, 2003 7:33 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): A lot of them
- Graphics Processor: Not Listed
- Contact:
Re: Bobbing functionality in ZScript?
Why build in (ha, ha ha) this specific functionality to the engine, when the entire weapon and viewport bobbing system could be externalized to ZScript to where the modder could alter it as they see fit? Then we could replicate any bobbing method from any game. Quake 3's pitch-and-roll system, LithTech's figure-eight, the floating-aim system from ARMA...all of that could be done per mod, without the engine needing to cater to individual whims.
Re: Bobbing functionality in ZScript?
A virtual function for bobbing would be godlike -- and is quite doable so I hear.
- Major Cooke
- Posts: 8170
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: Bobbing functionality in ZScript?
Bobbing's been exported. It's done in the player.
- nazakomu
- Posts: 131
- Joined: Wed Nov 30, 2016 12:51 am
- Graphics Processor: nVidia with Vulkan support
Re: Bobbing functionality in ZScript?
Yeah, I figured there was a way that was at least a hundred times better than what I suggested. This would be good too because I was thinking of the whole bobbing mechanism in Blood when the player jumps and it looks smooth and satisfying so that'd be awesome to see stuff like that in the future from here!wildweasel wrote:when the entire weapon and viewport bobbing system could be externalized to ZScript
Very happy to hear it!Xaser wrote:is quite doable so I hear.
Could you perhaps give a small example of what specifics could be tampered with as of now?Major Cooke wrote:It's done in the player.
- Major Cooke
- Posts: 8170
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: Bobbing functionality in ZScript?
When I need to mess with it I will. Currently I do not, and know nothing of it or where to even start.
- nazakomu
- Posts: 131
- Joined: Wed Nov 30, 2016 12:51 am
- Graphics Processor: nVidia with Vulkan support
Re: Bobbing functionality in ZScript?
Alright alright, we're probably better off with waiting until Graf decides to scriptify it anyways so then things will probably (hopefully) become as less intricate. Good luck to you when you choose to play with it!Major Cooke wrote:Currently I do not
Re: Bobbing functionality in ZScript?
Bob speed already affects the bobbing intensity, if you check gzdoom.pk3/zscript/shared/player.txt the bob function looks like this:
See how move is used as the second as the second argument of AngleToVector? That means that move controls the magnitude of the vector, meaning higher movement speeds give a higher bobbing intensity. The Bob function is called from the virtual MovePlayer, so if you want to change how bobbing works, you'll want to override MovePlayer and write your own Bob function (or, in some cases, it may be sufficient to just pass different arguments to Bob inside MovePlayer). Now of course, this isn't that adjustable, since the player.Vel vector controls how bobbing acts, but if you just want to control intensity of the normal Doom-style bobbing, that functionality is already here.
Code: Select all
void Bob (double angle, double move, bool forward)
{
if (forward && (waterlevel || bNoGravity) && Pitch != 0)
{
move *= cos(Pitch);
}
player.Vel += AngleToVector(angle, move);
}
- phantombeta
- Posts: 2084
- Joined: Thu May 02, 2013 1:27 am
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: Brazil
Re: Bobbing functionality in ZScript?
Seems like a DIY by this point, so I've closed it as such.