🔫Recoil Animation

In this section you will learn about procedural recoil animations.

The recoil system in the framework consists of these 3 main components:

  • Recoil Animation

  • Recoil Pattern

  • Camera Shake

In this chapter we will cover the procedural animations, and how to create that really nice and fluid recoil.

Component

Make sure to add the RecoilAnimation component to your character. This component will generate that smooth recoil in realtime, which will be applied by the Additive Layer.

This component has 3 main methods:

public void Play(); // Fired a gun, call it every shot.
public void Stop(); // Call it when fire key is released.
// Call this when a gun is equipped.
void Init(RecoilAnimData data, float fireRate, FireMode newFireMode);

Basic Properties

This asset contains animation curves and values for the recoil solver:

  • 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 maximum value is in [Z;W] range.

Aim Rot and Aim Loc define multipliers for each rotation and transaltion. Applied when aiming.

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 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 enbaled, 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.

Last updated