The Combat Manager Component is the most important component in the framework. It is the backbone for all other components and actors to operate, and should be present in every Pawn or Character considered a combatant.
For more information about how to extend this component, please check the Components and Extensions page. For now, we will simply add it to the base character class.
Add the Combat Manager Component
In your Base Character Class, add the Combat Manager Component.
Certain features, such as the Evade Ability, may require a global forward reference, a Scene Component that always points forward, typically an Arrow Component with absolute rotation.
The Combat Manager can create a default Forward Reference as needed, but if you are using Ninja Input, then you should create your own, so you can have the flexibility needed for that integration. For more details, please check Input Integration
Add a Forward Reference component
In your Base Character Class, create a new Arrow Component, parented to the Root Component.
Add the Combat.Component.ForwardReference tag to the list of Component Tags.
Set the Transform to use Absolute Rotation, so it always points forward.
Ninja Combat includes the NinjaCombatCharacterMovementComponent class, a version of the Character Movement Component that can handle different movement speeds, due to changes in blocking and strafing states.
Set the Combat Character Movement Component
In your Base Character Class, add the CombatSystemInterface.
Ninja Combat includes the NinjaCombatAnimInstance class, a version of the Animation Instance that can serve as the base class for an Animation Blueprint, handling animation updates related to blocking and strafing states.
Set the Combat Animation Instance
Create an Animation Blueprint, using NinjaCombatAnimInstance as the base class.
Set the new Animation Blueprint to your Character Mesh.
For more information about the properties and functions available in this Animation Instance class, please check the dedicated Character Animation page.
Combat System Interface
The Combat System Interface defines the contract that Pawns and Characters must follow, to integrate with Ninja Combat. All functions in this interface are optional, but let's implement some and go through the reasons why.
Function
Reason
GetCombatManager
The system performs a Component Scan to find the Combat Manager. Returning it avoids the component iteration.
GetCombatMesh
The system can find meshes tagged with Combat.Component.Mesh or the Character Mesh. Returning the mesh avoids component iteration, or obtaining the wrong mesh, in case of a Runtime Retargeting setup.
GetCombatAnimInstance
The Animation Instance from the Combat Mesh is always used. But if you have a Runtime Retargeting setup, you need to provide the Animation Blueprint that is actually driving the animation.
GetCombatForwardReference
The system can create a default Forward Reference, but if you are using Ninja Input, a custom Component Tag must be added to the Scene Component.
Add the Combat System Interface
In your Base Character Class, add the CombatSystemInterface.
Implement the GetCombatManager function, so it returns the Combat Manager Component.
Implement the GetCombatMesh function, so it returns the Character Mesh.
Implement the GetCombatAnimInstance function, so it returns the Character Animation Instance Blueprint.
Implement the GetCombatForwardReference function, so it returns the Forward Reference Component (e.g., the Arrow Component).
Header
// Ninja Bear Studio Inc., all rights reserved.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/NinjaGASCharacter.h"
#include "Interfaces/CombatSystemInterface.h"
#include "NBSCharacter.generated.h"
class UNinjaCombatManagerComponent;
UCLASS(Abstract)
class NBSTECH_API ANBSCharacter : public ANinjaGASCharacter, public ICombatSystemInterface
{
GENERATED_BODY()
public:
ANBSCharacter(const FObjectInitializer& ObjectInitializer);
// -- Begin CombatSystem implementation
virtual UNinjaCombatManagerComponent* GetCombatManager_Implementation() const override;
virtual USceneComponent* GetCombatForwardReference_Implementation() const override;
virtual USkeletalMeshComponent* GetCombatMesh_Implementation() const override;
virtual UAnimInstance* GetCombatAnimInstance_Implementation() const override;
// -- End CombatSystem implementation
private:
/** Forward Reference (Input and Combat integration). */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))
TObjectPtr<UArrowComponent> ForwardReference;
/** Combat Manager component. */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))
TObjectPtr<UNinjaCombatManagerComponent> CombatManager;
};