(Not involved with the making of the gun in-video)
When I see things like this here is what I see;
- Tick/delta based animations
- Gun wobble based on springs
- Gun bobbing based on a sin/cos curve
Tick()/delta based animation
Tick is an incredibly useful little function it;
Returns the number of seconds that have elapsed since the UNIX epoch (January 1st, 1970), on your computer. (Documentation - Roblox Creator Hub)
This means that every time it is called, you are at a seperate point in time. This allows us to find something really useful; Delta
Delta is the time between the current and last time something is called, tick() is something that can use this, but it also comes in some in-engine functions such as RenderStepped.
By using Delta’s, you can create smooth animations that shouldn’t change based on framerate. At 30 fps, it should still function the same as 60 fps. (Although, it will appear smoother on 60fps.) This is how everything here is being handled. Either by using the tick() to calculate the delta, or by using the in-engine methods.
Gun Wobble based on springs
I’ve only been introduced to springs in the last few months and to be perfectly honest, I am not at all familair with them. There is however a really good article here, but I’ll try and give you the jist of how I understand how to do it.
The gun model is being told that it needs to get from its current position, to its scoped position. You could really easily make a linear animation that goes from A to B, which I believe they do in the reload animation. For some games this is fine, for others it seems a little janky.
When the player moves their camera, the gun is still technically in the same position, but they are being told to be offset by X amount, to simulate a spring. This is a clamp, and a lot of games use it. (Look at a sniper in a cod montage doing a 1020 nocope at some insane camera speed. The gun will stay in one spot until the camera stops moving.) The spring is solved for every delta to give us the offsets.
Gun bobbing
The gun is moving along a Sine/Cos curve, based on the velocity of the character. I believe its how the breathing animation is being done. The person who coded this has likely given 3 or 4 states,
- Aiming
- Walking
- Running
- Idle
In all 4 of these states, they have their own ranges that the horizontal and vertical bobbing can be. Aiming will have a really small range, so that the player stays really close to being on-target. Walking will have an increased horizontal range, to simulate the body placing one foot infront of the other. Running has an even further increase horizontal range and a greater vertical range. All the while, Idle will have a reduced horizontal and vertical range, but probably still a greater vertical range, for the player’s ‘breathing’ up and down.
This is a mix of tick() and velocity based equations, which are always between its respective 1 and -1. By using them to solve the equation, it looks incredibly smooth. If you’d like an example of this, go into phantom forces and go from walking, to sprinting, then walking to dolphin-diving/sliding. When performing the last action, you should notice that your arms are going left and right waaaaaaay faster than they would running or walking.
anyway
Hope that answers your question, (this was supposed to be a really short answer…) if theres anything I’ve not picked up on, let me know and I’ll tell you what I know.