Weapon System

This doc explain the weapon design within Generic Combat System, and how to setup your weapon.

Cover.GCS
罗传月武(YueWu)

Author

罗传月武(YueWu)

专注游戏开发和Web技术。

Created: Apr 15, 2025Updated: Sep 10, 2026

Table of contents

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.

武器系统.001-en

How to implement weapon

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

武器系统.002-en
  • For regular users: You should copy BP_GCS_DemoWeapon to 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_DemoWeapon and create a weapon class that inherits from BP_GCS_Weapon to 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_WeaponActor or 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

武器系统.003
  • 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.

武器系统.Trace定义
  • 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 object for 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.

武器系统.基于Socket配置
Note: I specified Mesh as the SourceComponent for Trace in GetSourceComponentForTrace instead of using the Capsule component.
武器系统.基于Socket

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.

武器系统.基于Shape配置

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.

武器系统.009

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.