Recoil System

This section covers how to create, edit, and utilize recoil patterns in your game.

The Recoil System is the core mechanism of the Adaptive Recoil & Spread plugin that manages predictable weapon movement (kickback) during weapon fire.

Creating a New Recoil Pattern

  1. In the Content Browser, right-click and select Recoil & Spread → Recoil Pattern

  2. Name your pattern (e.g., "B_Recoil_Rifle")

  3. Double-click to open the pattern in the Recoil Pattern Editor

Recoil Pattern Editor

Recoil Pattern Editor

The Recoil Pattern Editor provides a visual interface to design your recoil patterns. It is WYSIWYG editor that means you can design your recoil points with high level precision and results will be the same as you design. Lets explain all the parts:

How it works?

When the player begins shooting, the current recoil index increases with each shot. With each increase, the recoil is re-calculated.

Key Formula: Recoil Delta = CurrentPoint - PreviousPoint

Example:

Recoil Point 1: (1.0, 1.5)
Recoil Point 2: (-1.5, 2.4)

Delta = (-1.5, 2.4) - (1.0, 1.5) = (-2.5, 0.9)  
Result: Crosshair will kickback "2.5" left and "0.9" up.

1- Crosshair Starting Point

It is the starting point of your crosshair on the screen. When you begin shooting, it will be using as a base point. You can not change it is position, it will always be at (0,0) point.

2- Recoil Point

When you create a recoil point in the pattern, it will has three properties: Yaw (X), Pitch (Y) values and Order Number. It is order number will be displayed on the screen and its value can change by using the Value Editing Tool.

3- Context Menu

When you right click to a recoil point or empty space in the editor a context menu will be shown up on the screen. It will show you available commands. All commands has its keyboard shortcut for easily editing.

Context Menu Command List:

Command
Behavior
Shortcut

Add Point

Adds a new recoil point that takes the (X,Y) values ​​at the mouse position.

Middle Mouse

Copy Point(s)

Select points and copy them to the clipboard.

Ctrl + C

Cut Point(s)

Select points and cut them to the clipboard.

Ctrl + X

Paste

All cut or copied recoil points will be pasted based on the mouse position (All are added as new recoil points).

Ctrl + V

Paste Override

All cut or copied recoil points will be pasted based on the mouse position (Recoil points that overlap with existing recoil points will be overridden).

Ctrl + V

Delete

Delete selected points.

Delete

Select

Only the marqued recoil points with the mouse will be selected.

-

Select All

Selects all recoil points in the pattern.

Ctrl + A

Fit

If there are selected recoil points, it will fit to the screen to cover only them, if not, it will fit to all recoil points.

F

4- Value Editing Tool

When select a point its (X,Y) values will be displayed in this tool. You can change (X,Y) values as you want. Also you can select multiple points and change their values at once.

5- Sort Point Tool

Automatically sort recoil points on the Y-axis by comparing their Y values. You can toggle its status (enable/disable) by clicking it.

6- Snap Grid Tool

This tool aligns recoil points to the nearest grid intersection when first time they created or while moving them if its enabled. You can toggle its status (enable/disable) by clicking it.

7- Axis Lock Tool

This tool restricts recoil point movement to specific axes (X, Y or Both). You can use this tool when ever you dont want to change recoil points X or Y values while moving them. Default setting is "Both" which means you can move your points in all directions.

8- Recoil Settings

The recoil system offers granular control over weapon kick behavior. Configure these core parameters as your needs.

Key Parameters

Parameter
Description

Enable/Disable Recoil

Toggles the entire recoil system on/off at runtime.

Recoil Speed

Controls interpolation between recoil points: - Acceleration: Ramp-up speed for recoil transitions - Max Speed: Hard limit for interpolation velocity

Max Recoil Camera Rotation

Absolute rotation limits (Pitch/Yaw) to prevent excessive camera movement. Example: (Pitch=15°, Yaw=10°) ensures recoil never exceeds these values.

Recoil Limit Behavior

Defines behavior when exhausting all points in the recoil pattern: 1. Repeat Pattern 🔁 - Loops back to first point - Example: Pattern A→B→C becomes A→B→C→A→B... 2. Use Last Point ⏹️ - Reuses final point's offset for subsequent shots - Example: Pattern A→B→C becomes A→B→C→C→C... 3. Stop ⏸️ - Immediately halts recoil after last point - Camera returns to intial position

Technical Notes

  • Pattern Execution: Shots progress through points sequentially (Point 1 → 2 → 3...)

  • Runtime Flexibility: All parameters can be modified mid-gameplay for dynamic tuning

  • Rotation Clamping: Max Recoil Camera Rotation applies hard limits using FMath::Clamp()

  • Network Sync: Recoil progression is server-authoritative with client prediction


Example Workflow

  1. Create recoil pattern with 5 points

  2. Set Limit Behavior to Repeat Pattern

  3. On 6th shot: System automatically uses Point 1

  4. On 11th shot: System uses Point 1 again

This configuration creates infinite recoil cycles until firing stops.

9- Relaxation Settings

Relaxation settings control how the camera returns to its initial position after recoil. Configure these parameters as your needs.

Parameters

Parameter
Description

Enable Relaxation

Enables/disables the relaxation system.

Enable Relaxation Only After End Shooting

If enabled, relaxation starts after shooting ends instead of after each shot.

Relaxation Delay

Delay (seconds) before relaxation activates after firing stops.

Relaxation Value Unit

Unit for MaxRelaxationPitch: - Absolute: Degrees. - Recoil Percent: Percentage of total recoil.

Relaxation Speed

Speed settings for relaxation interpolation (see FARSInterpolationSpeed).

Use Max Relaxation Pitch

Enables a maximum pitch limit for relaxation.

Max Relaxation Pitch

Relaxation stops when this value is reached: - Absolute: 1.0 = 1°. - Recoil Percent: 1.0 = 100% of total recoil.

Wait For Recoil End

Waits for all recoil to finish before starting relaxation.

Use Min Recoil Pitch For Relaxation

Requires a minimum recoil offset to activate relaxation.

Min Recoil Pitch For Relaxation

Minimum recoil pitch (degrees) to trigger relaxation.

Stop Relaxation By Input Type

How input interrupts relaxation: - NeverStopRelaxation: Input has no effect. - StopByAnyInput: Any input stops relaxation. - StopByInputInOppositeDirection: Only input opposing recoil direction stops it.

Stop Relaxation By Input Pitch

Minimum input threshold (e.g., mouse movement) to stop relaxation.

Example

If MaxRelaxationPitch = 0.5 with Recoil Percent unit:

  • Total recoil = 10° → Relaxation stops after recovering 5° (50% of total recoil).

10- Randomization Settings

Normally, recoil pattern behavior is predictibale because distance (delta) between two recoil points never changes. Randomization Settings allow you to add unpredictability to the recoil behavior using curves.

Parameters

Parameter
Description

RecoilRandomOffsetCurve

Defines random recoil offsets per shot: - X-axis: Shot index. - Y-axis: Random range (degrees) for Yaw (e.g., ±3°). - Z-axis: Unused.

RecoilRandomCompensationCurve

Reduces randomness based on previous shots: - X-axis: Normalized randomness (0–1) from the previous shot. - Y-axis: Multiplier (0–1) applied to current shot's randomness.

Example

RecoilRandomOffsetCurve at shot 5:

  • Y = 3 → Yaw varies between -3° to +3°.

RecoilRandomCompensationCurve:

  • Previous shot randomness = 0.8 (80%) → Curve returns 0.5 → Current shot’s randomness is halved.

Workflow

  1. Random Offset: Each shot applies a random offset from the curve.

  2. Compensation: The compensation curve scales subsequent randomness to prevent extreme buildup.

11- Recoil Modifiers

Recoil modifiers allow you to dynamically change recoil behavior based on gameplay conditions. You can define your recoil modifiers by using the UARSRecoilModifier class or other built-in modifiers. You can derive your class in both C++ or Blueprint.

Base Recoil Modifier Class:

UCLASS(Abstract, BlueprintType, Blueprintable, EditInlineNew, DefaultToInstanced)
class ADAPTIVERECOILSPREAD_API UARSRecoilModifier : public UObject
{
	GENERATED_BODY()

public:
	/**
	 * Modify recoil value after each shot
	 *
	 * DeltaTime - The time elapsed since the last frame, used for smooth interpolation and time-based calculations
	 * BaseRecoilRotation - The initial recoil value without any modifiers
	 * CurrentRecoilRotation - The recoil value after applying previous modifiers
	 * RecoilPattern - Owning recoil pattern asset
	 * RecoilSpreadManager - Owning Recoil and Spread Manager component from the controller
	 * @return - Final modified recoil rotation
	 */
	UFUNCTION(BlueprintNativeEvent)
	FRotator ModifyRecoil(float DeltaTime, FRotator BaseRecoilRotation, FRotator CurrentRecoilRotation, UARSRecoilPattern* RecoilPattern, UARSRecoilSpreadManager* RecoilSpreadManager);
	virtual FRotator ModifyRecoil_Implementation(float DeltaTime, FRotator BaseRecoilRotation, FRotator CurrentRecoilRotation, UARSRecoilPattern* RecoilPattern, UARSRecoilSpreadManager* RecoilSpreadManager);

};

Built-in Modifier Types

There are multiple recoil modifiers natively implemented in C++. You can directly use these modifiers or create your own modifiers derived from them:

  • UARSRecoilModifier_Crouch: Adjusts the recoil multiplier when the character is crouching

  • UARSRecoilModifier_JumpOrFall: Adjusts the recoil multiplier when the character is jumping or falling

  • UARSRecoilModifier_StandingStill: Reduces recoil when the character is standing still and smoothly transitions based on movement speed

Advanced

Creating Custom Modifiers

You can create custom modifiers by:

  1. Extending the UARSRecoilModifier class

  2. Implementing the ModifyRecoil method

  3. Adding your modifier to the weapon component

Below is an example of the built-in UARSRecoilModifier_Crouch recoil modifier:

Implementation Steps

1. Header File Implementation (UARSRecoilModifier_Crouch.h)

#pragma once

#include "ARSRecoilModifier.h"
#include "ARSRecoilModifier_Crouch.generated.h"

/**
 * Recoil modifier that adjusts the recoil multiplier when crouching
 */
UCLASS()
class ADAPTIVERECOILSPREAD_API UARSRecoilModifier_Crouch : public UARSRecoilModifier
{
	GENERATED_BODY()

public:
	// Override the ModifyRecoil function to adjust recoil based on crouching condition
	virtual FRotator ModifyRecoil_Implementation(float DeltaTime, FRotator BaseRecoilRotation, FRotator CurrentRecoilRotation, UARSRecoilPattern* RecoilPattern, UARSRecoilSpreadManager* RecoilSpreadManager) override;

protected:
	// Multiplier when crouching, smoothly blended based on TransitionRate_Crouching
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Recoil Params", meta=(ForceUnits=x))
	float RecoilMultiplier_Crouching = 0.8f;

	// Rate at which we transition to/from the crouching recoil (higher values are faster, zero is instant; @see FInterpTo)
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Recoil Params")
	float TransitionRate_Crouching = 5.0f;

private:
	// Current crouching recoil multiplier
	float CurrentCrouchingMultiplier = 1.0f;

	// Multiplier threshold for nearly equal comparison
	const float MultiplierNearlyEqualThreshold = 0.05f;
};

2. Source File Implementation (ARSRecoilModifier_Crouch.cpp)

#include "Modifiers/ARSRecoilModifier_Crouch.h"

#include "ARSLogChannels.h"
#include "Components/ARSRecoilSpreadManager.h"
#include "Core/ARSRecoilPattern.h"
#include "GameFramework/CharacterMovementComponent.h"
#include "GameFramework/Controller.h"
#include "GameFramework/Pawn.h"

#include UE_INLINE_GENERATED_CPP_BY_NAME(ARSRecoilModifier_Crouch)

FRotator UARSRecoilModifier_Crouch::ModifyRecoil_Implementation(float DeltaTime, FRotator BaseRecoilRotation, FRotator CurrentRecoilRotation, UARSRecoilPattern* RecoilPattern, UARSRecoilSpreadManager* RecoilSpreadManager)
{
	if (!RecoilSpreadManager)
	{
		UE_LOG(LogARS, Error, TEXT("[%s] RecoilSpreadManager component is null! Returning the current recoil rotation."), *FString(__FUNCTION__));
		return CurrentRecoilRotation;
	}

	if (!RecoilPattern)
	{
		UE_LOG(LogARS, Error, TEXT("[%s] RecoilPattern is null! Returning the current recoil rotation."), *FString(__FUNCTION__));
		return CurrentRecoilRotation;
	}

	AController* Controller = RecoilSpreadManager->GetController();
	APawn* Pawn = Controller ? Controller->GetPawn() : RecoilPattern->GetPawn();
	if (!Pawn)
	{
		UE_LOG(LogARS, Verbose, TEXT("[%s] Pawn is null! Returning the current recoil rotation."), *FString(__FUNCTION__));
		return CurrentRecoilRotation;
	}

	const UCharacterMovementComponent* CharMovementComp = Cast<UCharacterMovementComponent>(Pawn->GetMovementComponent());

	// Check if we are crouching and determine the target multiplier
	const bool bIsCrouching = (CharMovementComp != nullptr) && CharMovementComp->IsCrouching();
	const float CrouchingTargetValue = bIsCrouching ? RecoilMultiplier_Crouching : 1.0f;

	// Smoothly interpolate to the target value
	CurrentCrouchingMultiplier = FMath::FInterpTo(CurrentCrouchingMultiplier, CrouchingTargetValue, DeltaTime, TransitionRate_Crouching);

	// Apply the crouch multiplier to the current recoil rotation
	const FRotator ModifiedRecoilRotation = CurrentRecoilRotation * CurrentCrouchingMultiplier;

	// Log the applied recoil multiplier
	UE_LOG(LogARS, Verbose, TEXT("[%s] Applied crouching recoil multiplier: %f"), *FString(__FUNCTION__), CurrentCrouchingMultiplier);

	// Return the modified recoil rotation
	return ModifiedRecoilRotation;
}

Editor Preferences

ARS Editor Preferences

You can customize the appearance and workflow of the Recoil Pattern Editor in real time via Unreal Editor > Preferences > Adaptive Recoil Spread. Changes are applied instantly while the editor is open.


1. Point Node Appearance Settings

Controls the visual representation of recoil points.

Parameter
Description
Default Value

Visual Type

Node shape: Circle, Diamond, Hexagon, Square, Star

Diamond

Point Size

Node dimensions (in pixels)

11x11

Default Color

Color of unselected nodes

#333333 (Dark Gray)

Selected Color

Color of selected nodes

#FFFFFF (White)

Numbering Text Color

Index number text color

White

Numbering Text Size

Index number font size

12


2. Point Connection Settings

Configures lines connecting recoil points.

Parameter
Description
Default Value

Line Color

Connection line color

White

Line Thickness

Line thickness (pixels)

2


3. General Editor Settings

Core editor behavior and visual features.

Parameter
Description

Auto Sort Points

Automatically sorts points when added

Show Point ToolTip

Disables tooltips on node hover

Auto Frame

Automatically zooms to fit all points when pattern changes

Show Bars

Toggles X/Y axis measurement bars

Use Aspect Ratio When Zoom To Fit

Maintains aspect ratio during zoom-to-fit

Snap Axis

Axis locking during dragging: None (Disabled), X Only (Horizontal), Y Only (Vertical)

Snap X To Selection

Aligns dragged nodes to X-axis of selected point

Frame Padding

Margin during zoom-to-fit: X Padding=50px, Y Padding=50px


4. Usage Scenarios

Scenario 1: Rapid Visual Customization

  1. Set PointSettings -> DefaultColor to #FF0000 (Red).

  2. Change Visual Type to Star.

  3. Result: All nodes instantly become red stars.

Scenario 2: Smart Workspace Management

  1. Enable Auto Frame and Use Aspect Ratio.

  2. Add new points.

  3. Result: Editor automatically adjusts viewport to frame all points.

Scenario 3: Precision Editing

  1. Set Snap Axis to X Only.

  2. Drag a node horizontally.

  3. Result: Node movement is constrained to the X-axis.


5. Resetting to Defaults

Use the ResetToDefaults() button in each settings category to restore original values. ⚠️ Warning: This action cannot be undone!

Last updated