🔫
PRAS Documentation
  • 👋Welcome!
  • Tutorial
    • 🌟Getting Set Up
      • 🦾Character Setup
      • 🔶Animation Blueprint
  • Fundamentals
    • 🔥Recoil Animation
    • 📈Curve Extractor
    • 📑Types
      • URecoilAnimationComponent
      • FAnimNode_RecoilAnimation
      • Recoil Data
Powered by GitBook
On this page
  • Step 1 - Add the RecoilAnimation component
  • Step 2 - Integration
  • Init
  • Play/Stop
  • Set Fire Mode
  • Set Aiming Status
  • Step 3 - Add data to the Weapon
  1. Tutorial
  2. Getting Set Up

Character Setup

In this section you will learn how to set up a character

PreviousGetting Set UpNextAnimation Blueprint

Last updated 1 year ago

Tip: all the functionality below is available to both Blueprints and C++.

Step 1 - Add the RecoilAnimation component

First off, you need to add the recoil component to your character. You can do it in both Blueprints and C++:

YourCharacterClass.h
UCLASS(config=Game)
class AYourCharacterClass : public ACharacter
{
    GENERATED_BODY()

public:
    AYourCharacterClass();

protected:
    UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Recoil")
    TObjectPtr<URecoilAnimationComponent> RecoilComponent;

    ...
};
YourCharacterClass.cpp
AYourCharacterClass::AYourCharacterClass()
{
    ...
    RecoilComponent = CreateDefaultSubobject<URecoilAnimationComponent>(TEXT("RecoilComponent"));
    ...
}

Then, in your character class click on the RecoilAnimation component and specify the Helper UI:

The Helper UI is useful when you want to modify the recoil values in runtime in a very convenient way:

To enable this Helper UI in the game you can use the Blueprint-exposed methods:

Step 2 - Integration

Now it's time to call PRAS-related functions. Here're the events PRAS needs to generate top-notch recoil:

Init

This method must be called when a new weapon is equipped. You need to pass the crucial information from your weapon to the RecoilAnimation component:

Data - Recoil AnimatioData struct, that contains curves and a Recoil Data Asset:

Play/Stop

Call these methods when firing and stop firing respectively.

Tip: Play must be called when every shot is fired, it's required for the auto and burst fire modes to work properly.

Set Fire Mode

Call this method when a fire mode is updated:

Set Aiming Status

When a player aiming state is updated, make sure to call this method to affect the recoil during ADS:

Step 3 - Add data to the Weapon

The final step is to add the Recoil Anim Data struct to your weapon:

Weapon.h
UCLASS(BlueprintType)
class PRAS_DEMOPROJECT_API AWeapon : public AActor
{
    GENERATED_BODY()
	
    AWeapon();

public:
    // Add a new property to your class
    UPROPERTY(EditDefaultsOnly, Category = "Animation")
    FRecoilAnimData RecoilAnimData;
    ...
};

Example:

Populate this struct with Curves and Recoil Data Assets in your weapon blueprints. You can get the example assets in.

🌟
🦾
Step 1 - Installing the plugin
Select this Blueprint asset
Example from the demo project
Example from the demo
Make sure to assign the curves, slot name and a Stored Data asset!
Note: Event On Fire Pressed is called every shot!
Add this property to your base weapon class