Ninja Bear Studio Plugins Help

Create a Melee Weapon

This how-to will show you how to create your first Melee Weapon and assign it to the default Weapon Manager.

Create your Sword Weapon actor

  1. Create a new Actor extending from NinjaCombatWeaponActor and name it BP_Weapon_Sword.

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

    Create the Weapon Tags
  3. Create a Static Mesh Component and set the mesh for your Weapon.

    Create the Weapon Mesh
  4. Set the Weapon Collision to Overlap All, since the system uses traces to scan for targets.

  5. Add the Combat.Component.MeleeScanSource tag to your Static Mesh Component, so the Weapon Actor will be able to find the Weapon Mesh.

Create your Shield Weapon actor

  1. Create a new Actor extending from NinjaCombatWeaponActor and name it BP_Weapon_Shield.

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

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

Configure the Weapon Manager

  1. Implement the Combat System Interface along with the GetCombatMesh and GetWeaponManager functions.

    In the Components tab, search for weapon 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 Blueprints tab, expand the Combat System Interface and double-click Get Weapon Manager Component. Implement it returning the Weapon Manager.


    Weapon Manager in the Combat System Interface

    Still in the Blueprints tab, double-click Get Combat Mesh. Implement it returning the main Character Mesh for your Blueprint.


    Combat Mesh in the Combat System Interface

    Add CombatSystemInterface to your header and create a pointer to the Weapon Manager.

    Override the GetCombatMesh and GetWeaponManagerComponent functions.


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

    Initialize the Weapon Manager instance and return it from the appropriate function. Do the same for the Character Mesh.


    #include "GameFramework/PluginLabsCharacter.h" #include "Components/NinjaCombatWeaponManagerComponent.h" APluginLabsCharacter::APluginLabsCharacter(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { static const FName LeaderMeshName = TEXT("LeaderMesh"); LeaderMesh = CreateDefaultSubobject<USkeletalMeshComponent>(LeaderMeshName); // ... static const FName WeaponManagerName = TEXT("WeaponManager"); WeaponManager = CreateDefaultSubobject<UNinjaCombatWeaponManagerComponent>(WeaponManagerName); } USkeletalMeshComponent* APluginLabsCharacter::GetCombatMesh_Implementation() const { return LeaderMesh; } UActorComponent* APluginLabsCharacter::GetWeaponManagerComponent_Implementation() const { return WeaponManager; }
  2. Add your weapons to the Weapon Manager's Details Tab and configure them to the correct sockets in your Character's Mesh Skeleton.

    Adding Weapons to the Weapon Manager

Check the Weapon Manager configuration

  1. Click the Play button.

  2. Your character should start with the both weapons attached to the correct sockets.

    Combatant with attached weapons
Last modified: 15 August 2024