π«Recoil Animation
In this section you will learn how to work with recoil .
Recoil Animation Component
Recoil Animation is a component that generates smooth and fluid firing animations at runtime:

This component has 3 methods that need to be called in the shooting code:
Recoil Anim Data
Recoil parameters are defined in the RecoilAnimData β a Scriptable Object that can be created via right-click βΈ Create βΈ KINEMATION βΈ Procedural Recoil βΈ Recoil Data:

Pitch - max and min values for the pitch (up) rotation
Roll - max and min values for the roll rotation.
Yaw - max and min values for the yaw (right) rotation.
Roll and Yaw components are Vector4. That's because of the way random values are calculated:
Minimum value for Roll and Yaw is a random value in [X;Y] range, while the maximum value is in [Z;W] range.
Aim Rot and Aim Loc define multipliers for each rotation and translation. Applied when aiming.
Smooth Rot/Loc - defines interpolation speed for rotation and translation. Not applied if 0. Extra Rot/Loc - multipliers applied in auto/burst mode only.
Noise layer is a continuous 2D movement that simulates inaccuracy when firing.
Noise X/Y - max and min values for position offsets along X and Y axes (right and up movement).
Noise Accel - acceleration speed.
Noise Damp - damping speed. Noise Scalar - aiming multiplier.
Pushback layer is applied on the first shot of the auto or burst fire mode.
Push Amount - maximum value of the pushback.
Push Accel - acceleration speed.
Push Damp - damping speed.
Hip Pivot Offset - weapon pivot offset when hip firing.
Aim Pivot Offset - weapon pivot offset when aiming.
Smooth Roll - if enabled, the sign of a random value for roll will change every shot.
Play Rate - the speed of the recoil animation.
Recoil Curves - normalized animation curves.
Recoil Curves
There are 4 Vector curves in the data asset, where each Vector curve is designed to animate the rotation or translation when auto/single firing.

Tip: All curves must start and end with zero!
Here's the difference between auto and semi curves:


Curves are almost identical, the only difference is that the Auto curve value is very close to zero at some point - this point is the delay between shots.
Example: let's say our fire rate is 600 RPM, then the delay between shots is 0.1s. This means, that all auto curves must be close to 0 at 0.1s time.
Tip: This is required for the auto solver to work properly. When auto/burst mode is enabled, the curve length is set to the fire delay (see our example above). So, the length of the auto or burst curve gets cropped to the fire delay between shots.
How to apply recoil animation
Add the Recoil Animation component to the character's prefab and apply the changes. Then, add a "Modify Bone" modifier to the Procedural Animation settings and bind recoil OutRot and OutLoc values:

Last updated