New Weapon {{ currentPage ? currentPage.title : "" }}

You can use an existing type of weapon, but if you want to create a new type of weapon you need to add a new row to the E_WeaponType enumeration (Picture 1).

 

Picture 1 - Weapon types enumeration

Each weapon can have multiple fire modes. If you want to add your own mode - you need to add a new row to the E_Firemodes enumeration (Picture 2). To create a new weapon you need to add a new row in the weapon data table and initialize all required information.

Picture 2 - Fire modes enumeration

Then you need to add a new row in the Weapons data table. (Picture 3)

Picture 3 - Weapon data table

 Now you can create an actor that will be connected to your hands. This actor will be spawned in your hands when you equip the weapon. In the actor you need to initialize skeletal mesh. You can rotate components or add any other particle effect or static meshes. If you want to use static mesh - you need to override the “GetUsedSceneComponent” function and set static mesh there in the output. 

Picture 4 - Connected mesh child for the new weapon

Picture 5 - New Anim BP for your weapon

Picture 6 - ABP_Pistol

Picture 7 - Weapon setup in connected mesh

Then you need to add a new row in the items data table. You need this to be able to use this information if actors and store dynamic information like current ammo and amount (Picture 8). 

After you created an actor to connect to your hands you need to initialize with this actor ActorToConnect variable in the items data table. 

Picture 8 - DT_Items setup

You can also create interactable objects if you want to be able to take this object in the world (Picture 9). In this interactable object you need to initialize the Actor variable with your new row from items data table.

Picture 9 - Create child from interactable object for a new weapon

Picture 10 - Setup interactable object with a new row

There are several sockets that are used in the project. If you want to have a muzzle effect on your weapon - you need to add a “Muzzle” socket (Picture 11). To spawn shells after you shoot - you need to have a “Shells” socket. The last socket is “Laser”, you need to use it to make a place you will trace the laser from. All sockets you can find in the pistol skeleton.  

Picture 11 - Add new sockets to the weapon

Now you can use weapons in the game. You are faced with a problem that manifests itself gradually.

Picture 12 - Issue

Picture 13 - Solution

Picture 14 - Result

{{{ content }}}