Ninja Bear Studio Plugins Help

Create Melee Weapons

After configuring the initial Combat Components, the first step in Ninja Combat is to prepare your character for Melee Attacks using a Melee Weapon, which must be registered with the Weapon Manager.

Create a sword

  1. Create a new Actor extending from NinjaCombatWeaponActor. This will be our sword.

  2. Set Inventory.Item.Type.Sword to the Weapon Tags container.

    Sword Tags
  3. Add a Static Mesh to this Actor, set your sword mesh to it, and add the Component Tag Combat.Component.MeleeScanSource.

    Sword Mesh
  4. Set the mesh's collision to Overlap All. The system uses traces to collect targets, and we do not want the weapon colliding with other objects.

    Sword Mesh Collisions

Create a shield

  1. Create a new Actor extending from NinjaCombatWeaponActor, or from your base Blueprint. This will be our shield.

  2. Set Inventory.Item.Type.Shield to the Weapon Tags container.

    shield Tags
  3. Repeat the same steps as before, setting the Weapon Collision and tagging the Static Mesh Component.

Configure the Combat Components

  • In your Player Character, add the Combat Manager Component, Weapon Manager Component and implement the Combat System Interface.

    In the Components tab, search for combat manager and select the Ninja Combat Manager component.


    Combat Manager Component

    In the Components tab, search for weapon manager and select the Ninja Combat Weapon Manager component.


    Weapon Manager Component

    In the Class Settings view, add the Combat System Interface.


    Combat System Interface

    In the My Blueprint tab, under Interfaces, expand the Combat System Interface:

    • Double-click GetCombatManagerComponent and return the Combat Manager component.

    • Double-click GetWeaponManagerComponent and return the Weapon Manager component.

    • Double-click GetCombatMesh and return the Character Mesh.

    • Add CombatSystemInterface to your Player Character class.

    • Create an instance of UNinjaCombatManagerComponent and return it from GetCombatManager_Implementation

    • Create an instance of UNinjaCombatWeaponManagerComponent and return it from GetWeaponManagerComponent_Implementation

    • Return the character's mesh from GetCombatMesh_Implementation


    #pragma once #include "CoreMinimal.h" #include "GameFramework/Character.h" #include "Interfaces/CombatSystemInterface.h" #include "PluginLabsCharacter.generated.h" class UNinjaCombatManagerComponent; class UNinjaCombatWeaponManagerComponent; UCLASS() class PLUGINLABS_API APluginLabsCharacter : public ANinjaGASPlayerCharacter, public ICombatSystemInterface { GENERATED_BODY() public: APluginLabsCharacter(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get()); // -- Begin Combat System Implementation. virtual USkeletalMeshComponent* GetCombatMesh_Implementation() const override; virtual UNinjaCombatManagerComponent* GetCombatManagerComponent_Implementation() const override; virtual UActorComponent* GetWeaponManagerComponent_Implementation() const override; // -- End Combat System Implementation. private: /** Main Manager for the Combat System. */ UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Components", meta = (AllowPrivateAccess = true)) TObjectPtr<UNinjaCombatManagerComponent> CombatManager; /** Weapon Manager component that will manage weapons for this character. */ UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Components", meta = (AllowPrivateAccess = true)) TObjectPtr<UNinjaCombatWeaponManagerComponent> WeaponManager; };

    #include "GameFramework/PluginLabsCharacter.h" #include "Components/NinjaCombatManagerComponent.h" #include "Components/NinjaCombatWeaponManagerComponent.h" APluginLabsCharacter::APluginLabsCharacter(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { static const FName CombatManagerName = TEXT("CombatManager"); CombatManager = CreateDefaultSubobject<UNinjaCombatManagerComponent>(CombatManagerName); static const FName WeaponManagerName = TEXT("WeaponManager"); WeaponManager = CreateDefaultSubobject<UNinjaCombatWeaponManagerComponent>(WeaponManagerName); } USkeletalMeshComponent* APluginLabsCharacter::GetCombatMesh_Implementation() const { return GetMesh(); } UNinjaCombatManagerComponent* APluginLabsCharacter::GetCombatManager_Implementation() const { return CombatManager; } UActorComponent* APluginLabsCharacter::GetWeaponManagerComponent_Implementation() const { return WeaponManager; }

Configure the Weapon Manager

  1. Open your character's Skeleton and add sockets for the sword and shield.

  2. Add your weapons to the Weapon Manager's Details Tab and configure them to the appropriate sockets in your Character's Mesh Skeleton.

    Adding Weapons to the Weapon Manager

Test everything

  1. Press play, you should see your Player Character, as usual.

  2. Your character should have a sword and a shield attacked to the correct sockets.

Weapons added to the character
Last modified: 25 October 2024