Introduction
Weapons are objects that exist in most games with combat elements.
To make the weapon system easy to integrate, GCS provides the GCS_WeaponInterface and includes BP_GCS_DemoWeapon as the default implementation in the reference project to help you get started quickly.
Design Diagram
This design diagram describes the overall design of this weapon system.

How to implement weapon
In GCS, there are several ways to implement weapons. Below is the inheritance chain for weapon classes.

- For regular users: You should copy
BP_GCS_DemoWeaponto create a new class as the parent class for all your weapons and customize it accordingly. - For integration: If you want to integrate with other systems, refer to
BP_GCS_DemoWeaponand create a weapon class that inherits fromBP_GCS_Weaponto serve as the parent class for all your weapons, and then customize it. - For advanced users: you can directly inherit from the C++ class
GCS_WeaponActoror create your own weapon actor entirely and implement the weapon interface (GCS_WeaponInterface) directly.
Default Weapon Implementation
The demo project also includes a weapon parent class: BP_GCS_DemoWeapon. You can create new weapon types by making a subclass of this blueprint. The weapon blueprint supports both SkeletalMesh and StaticMesh.
Default Parameters for Weapons

- Active/Inactive Sockets: Weapons can have active and inactive states, and you can specify which socket on the character's mesh the weapon should be attached to in both states.
- WeaponAbilitySets: You can add multiple ability sets to the weapon. When the weapon is activated, these ability sets will be granted to the character's ability system component, and they will be removed when the weapon is deactivated.
- AbilityActionSet: You can also associate an ability action set setting with the weapon, allowing the character to query and select corresponding ability actions from the weapon's associated ability action set when executing various abilities.
If you already have an existing project or are not satisfied with the default implementation, you can completely create your own Actor/Component/UObject and implement the GCS_WeaponInterface.
Weapon Collision Trace Setup
Weapons can setup multiple trace definition, so the weapon itself does not need to enable collision.

- Depending on your requirements for weapon collision detection accuracy, you can choose the appropriate Trace shape and Tick method. You can also set multiple Trace definitions to represent hitboxes for different parts of the weapon.
- When the weapon's activation state changes, the corresponding trace instance is added to or removed from the weapon's Owner's TraceSystem, with the weapon itself as the
source objectfor tracking. Learn more about the Collision Trace System.
Socket-based Trace
In the weapon's TraceDefinition settings, you can select the SocketBased detection shape, which will dynamically construct the capsule in the Trace's SourceComponent based on the specified MeshSocketStart/MeshSocketEnd.

Note: I specified Mesh as the SourceComponent for Trace in GetSourceComponentForTrace instead of using the Capsule component.
The specific sockets used for MeshSocketStart/MeshSocketEnd are defined in the static mesh editor.
In the game, it forms a dynamic capsule based on the Mesh's Socket.
Shape-based Trace
You can also choose ShapeBased detection shape, without having to add a bunch of sockets to the Mesh, but you'll need to add a Shape component to the weapon and override the weapon's GetSourceComponentForTrace to return the Shape component.

The selected collision shape must match the SourceComponent type, so that the width/size of the shape is determined by the Shape component.
You can still define the shape's position and rotation offset (relative to the Shape component's coordinate space).
In the game, the collision detection system detects collisions based on the shape/size of the Shape component.
Weapon Interface
In most cases, you can use GCS_WeaponInterface to obtain various information related to the weapon itself or modify its state. For GCS, a weapon is just an object (it can be an Actor, a Component, or even a UObject) that contains information and state about the weapon.
Thus, the default implementation of the weapon interface in GCS is completed in the form of an Actor.
Further Reading
In real game development, weapon systems are usually part of complex inventory/equipment systems, and depending on these systems, weapons can be created in completely different ways. For example, in Lyra, weapons are represented as UObjects, and a weapon can have multiple Actors as its visual representation, such as "dual sword".
Default Weapon Management Component
The provided project includes a simple weapon manager component (BC_GCS_DemoWeaponManager) suitable for scenarios where a character has only one weapon at a time. You will add it to your combat character and configure 1 to N weapon information, allowing weapon switching through a simple API.

The BC_DemoCombatEnitycomponent will return the character's current weapon through this weapon management component.
Integrating Other Weapon Management Component
You can refer to BC_DemoCombatEnity(inherit from BC_GCS_CombatEntity), and return the specified weapon object through the corresponding overloaded functions using other weapon/inventory systems, as long as the object implements the GCS_WeaponInterface.
