API Reference

7. API Reference

This section provides a detailed reference of the main classes, functions, and data types in the Adaptive Recoil & Spread plugin.

Core Components

UARSWeaponComponent

This component handles weapon recoil and spread behaviors for weapon actors.

Public Functions:

// Lifecycle
virtual void BeginPlay() override;

/** Begin weapon firing sequence */
virtual void BeginFiring();

/** Call for every weapon fire */
virtual void Fire();

/** End weapon firing sequence */
virtual void EndFiring();

/** Immediately stop the active recoil. */
virtual void StopRecoil();

/** Stop the recoil relaxation process. */
virtual void StopRelaxation();

// Recoil Pattern Management
void SetRecoilPattern(UARSRecoilPattern* InRecoilPattern);
UARSRecoilPattern* GetRecoilPattern() const;

/** Apply the current spread. */
virtual void ApplySpread();

// Spread Management
void SetSpreadPattern(UARSSpreadPattern* InSpreadPattern);
UARSSpreadPattern* GetSpreadPattern() const;

/** Get the controller (player or AI) associated with RecoilSpreadManager component. */
AController* GetController() const;

/** Get the RecoilSpreadManager component from the controller */
UARSRecoilSpreadManager* GetRecoilSpreadManager() const;

Properties:

// Default recoil pattern assigned in editor
UPROPERTY(EditAnywhere, Category = "Weapon Component")
TObjectPtr<UARSRecoilPattern> DefaultRecoilPattern;

// Currently active recoil pattern asset
UPROPERTY(Transient)
TObjectPtr<UARSRecoilPattern> RecoilPattern;

// Default spread pattern assigned in editor
UPROPERTY(EditAnywhere, Category = "Weapon Component")
TObjectPtr<UARSSpreadPattern> DefaultSpreadPattern;

// Currently active spread pattern asset
UPROPERTY(Transient)
TObjectPtr<UARSSpreadPattern> SpreadPattern;

UARSRecoilSpreadManager

Component that manages recoil and spread behaviors for controllers (both player and AI).

Public Functions:

// Constructor
UARSRecoilSpreadManager(const FObjectInitializer& ObjectInitializer);

// Lifecycle
virtual void BeginPlay() override;
virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

// Recoil Pattern Management
/** Begin firing sequence using the specified recoil pattern. */
virtual void BeginFiring(UARSRecoilPattern* RecoilPattern);

/** Call for every weapon fire. Increase the recoil step and update values (update offsets and apply randomness). */
virtual void Fire();

/** End the firing sequence. */
virtual void EndFiring();

/** Immediately stop the active recoil. */
virtual void StopRecoil();

/** Stop the recoil relaxation process. */
virtual void StopRelaxation();

/** Updates the last input from the controller (player or AI). */
virtual void UpdateControlInput();

/** Get the controller (player or AI) associated with this Recoil Spread Manager. */
AController* GetController() const;

/** Get the current control rotation of the associated controller. */
FRotator GetControlRotation() const;

/** Set the control rotation of the associated controller. */
void SetControlRotation(const FRotator& Rotation);

// Spread Pattern Management
/** Apply the current spread. */
virtual void ApplySpread();

/** Get the current spread pattern asset. */
UARSSpreadPattern* GetSpreadPattern() const;

/** Set the current spread pattern asset. */
void SetSpreadPattern(UARSSpreadPattern* InSpreadPattern);

// Debug
/** Check if debug visualization is enabled. */
virtual bool IsDebugEnabled() const;

/** Display recoil debug information on-screen. */
virtual void ShowRecoilDebug();

/** Display spread debug information on-screen. */
virtual void ShowSpreadDebug();

/** Notify the system of a debug shot hit at the given location. */
virtual void NotifyDebugShotHit(FVector HitLocation);

Recoil Point Collections

The ARSRecoilPointCollection is the primary data structure that stores recoil points and provides APIs for point manipulation:

  • Points: A series of 2D vectors representing pitch (Y) and yaw (X) offset

Last updated