Weapon System


1 Overview

The weapon system is one of the most important system in our framework for shooting game. This document will explain how to setup the game mode based our framework.


2 Basic Setup

Notice that the basic setup have been done for the build-in character of our framework, you can directly create the child blueprint of BP_Character_USG and the weapon system is activated already.

The following setup steps indicate how to use the weapon system for the new character.

Add the following weapon component to your character blueprint:

  • /Game/USGT/Framework/Character/Weapon/BP_CharacterWeaponComp_USG

weaponsetup


  • WeaponSlots: One player can have several weapon slots which will decide how many weapons the player can equip.

To activate damage and effect of the weapon system, you also need to add two interface blueprints to your character. Override the interfaces for your character according to your requirement.


weaponinterface


3 Weapon Creation Flow

See the weapon example from following folder.

  • /Game/USGT/Game/CoreModules/Weapon/Rifle

3.1 Create Weapon Blueprint


Firstly, create the weapon blueprint based on the BP_GameShootWeaponBase. See the following blueprint as an example.

  • /Game/USGT/Game/CoreModules/Weapon/Rifle/BP_Weapon_Rifle

Config following properties.


weaponclass


Important properites for weapon configuration.

  • DebugShootTraceLine: If true, the debug shooting trace line will be displayed.

  • ShootingRange: The max bullet shooting range of current weapon.

  • MuzzleSocketName: Muzzle socket name from the weapon skeletal.

  • BulletSpeed: The move speed of the bullet for this weapon.

  • BulletClass: The bullet class for this weapon.

  • BulletItemID: The item id of bullet, which will be use to find the appropriate bullet for this weapon from inventory.

  • IsPointDamage: If true, this weapon will cause point damage, otherwise, it will cause normal damage (which will notify the injured actor or pawn).

  • FireAudio: Fire audio asset.

  • DefaultFireMode: Default fire mode for this weapon

  • SupportedFireMode: Supported fire mode for this weapon (single, auto and burst mode).

  • MaxCanLoadedBullet: Max bullet number which can be loaded for this weapon.

  • PelletsPerShot: Pellet number for each shooting.

  • BurstFireInterval: Shooing interval for burst shooting mode.

  • BurstFireBullets: Bullet number for each shooting at burst mode.

  • AnimConfig: Animation config for this weapon, such as reload montage.

  • AutoReload: If true, this weapon will try reload after bullets running out.

  • MaleLinkAnimClass: Link animation class for male character.

  • FemaleLinkAnimClass: Link animation class for female character.

  • BaseDamage: Basic damage value for this weapon.

  • DamageTypeClass: Damage type class for this weapon which is used for some complex or special damage types.

  • CrossHairConfig: Cross hair config for this weapon, including cross hair widget class and cross hair radius.

  • EquipAttachInfo: The attached location at character mesh for this weapon after equipping, including attach socket and attach rule.

  • DefaultUnequipAttachInfo: The attached location at character mesh for this weapon after unequipping,

  • UnequipAttachSlotInfo: If this weapon can be equipped at different slots, then you need to config the attached location detail for each slot.


3.2 Create Item Entity and Pickup Entity


See the item creation flow at section 3 of Item System chapter.

Create the child item entity blueprint of BP_WeaponItem_USG and config following properties.


itementity


  • WeaponType: Weapon type of current weapon.

  • WeaponClass: Weapon class created at section 3.1.

  • DiscardWhenReplaced: If true, the weapon item will be discarded if other weapon equipped at same slot.


3.3 Customize Weapon Trajectory


The weapon trajectory is very important for a shooting game as different weapon has different recoil. For the continuous shooting, the bullet spread is influenced by different factors, including recoil and other physical factors.

See the following example to customize the weapon trajectory for your own weapon.


trajectory


  • CameraShake: Camera shake for shooting.

  • RecoilIncrement: Recoil increment for each shot.

  • RecoilDecreaseSpeed: Recoil decrease speed for continuous shooting.

  • SpreadMultiplierMax: Max multiplication fator of spread.

  • SpreadMultiplierCrouching: Max multiplication fator of spread while crouching.

  • SpreadMultiplierADS: Max multiplication fator of spread while ADS.

  • SpreadMultiplierScope: Max multiplication fator of spread while Scoping.

  • SpreadPitchMax: Max pitch spread of one shooting.

  • RecoilToSpreadCurve: Curve corresponding the relationship between recoil and spread.

  • RecoilToPitchCurve: Curve corresponding the relationship between recoil and pitch.

  • RecoilToYawCurve: Curve corresponding the relationship between recoil and yaw.

Adjust above parameters to get the different bullet spread of shooting.


TestWeapon