Scene Graph provides a way to create custom ranged weapons with an entity prefab. Custom weapons are modifiable in the Prefab Editor, or through Verse. Your custom weapons are immediately ready to use with Fortnite Characters, and can be picked up and dropped, stored in inventories, reloaded, aimed, and fired.
Choose from four different weapon templates:
Assault Rifle (assault_rifle_template)
Sub Machine Gun (sub_machine_gun_template)
Pistol (pistol_template)
Shotgun (shotgun_template)
Weapon templates include all the necessary Scene Graph components for a fully featured and functional weapon item:
description_component: For name and descriptions.
icon_component: Display a weapon icon in the HUD.
rarity_component: Displays how rare the weapon is.
mesh_component: A specific weapon template.
All weapon meshes can be removed and replaced.
fort_item_pickup_interactable_component: Provides a way for a player to pick up the weapon.
item_component: Designates the entity prefab as an item so it can be equipped and stored in player inventories.
fort_trace_weapon_component: Adds customizable weapon fields (damage, range, and more).
fort_multi_trace_weapon_component (shotgun_template only): Adds customizable weapon fields (damage, range, and more).
Create a Custom Weapon
Follow the steps below to create your own custom weapon.
Custom Items and Inventory
Open Project Settings and scroll to the Beta Access section.
Expand the Beta Access section and check the Custom Items and Inventory box setting it to True.
Scene Graph System is checked by default.
Create an Entity Prefab
Right-click in the content browser and select Entity Prefab from the dropdown menu. The Create Entity Prefab Definition window opens.
Expand the Entity option in the Create Entity Prefab Definition window.
Select a weapon template from the four available options. Templates provide default states and a suitable mesh.
Name your new prefab and save it.
Customize Your Weapon
Double-click the prefab thumbnail in the content browser to open the Prefab Editor. From the editor you’ll see all the modifiable components. To customize your weapon, do the following:
Select the weapon base entity in the outliner.
Select the
fort_trace_weapon_componentin the Details panel.Weapon templates already have a number of components ready for you to edit and modify. The
fort_trace_weapon_componentandfort_multi_trace_weapon_componenthold all the properties relating to the weapon behavior.Modifiable fields are available under the following categories.
Damage(per shot) andRangeDamageMultiplier: The weapon’s damage values.MaxRangeandFireRate: Controls the weapon shot.AimDownSightSpreadMultiplierandCrouchingSpreadMultiplier: Determines the weapon’s accuracy.MuzzleFlash(particle effect) andWeaponFireSound: Weapon visual and audio effects.
Change the
DamageorFireRateproperties on your custom weapon to determine the amount of damage the weapon does and to control the weapon’s shot.Delete the
assault_rifle_mesh_componentto replace the weapon mesh.Add a new
mesh_component.Some things to consider when importing a new mesh to serve as the weapon:
You need to change the default Collision Preset in your imported mesh to OverlapAll (or another preset that does not block characters).
Ensure that your mesh pivot is centred on your weapon mesh’s handle. That is where the character’s gripping hand will be.
Collision PresetsSet a new name and description inside the
description_component.Add a new icon image for the weapon inside the
icon_component.You can add custom components you have written yourself in Verse.
Test Your Custom Weapon
You should test your custom weapon to make sure it behaves the way you expect. Drag the entity prefab into the viewport to place an instance of the weapon into your project, then select Launch Session.
Create a Custom Weapon with Verse
You can use Verse to modify custom weapons at runtime using the Armory module.
The Armory Module
The Template Weapons API is accessible in the Fortnite.digest.verse code digest in Visual Studio Code. Under the Armory public module you’ll find the following fort_trace_weapon_component definitions:
Editable functions and fields
Mesh asset reference
With Verse you can:
Use a variable and an event in the
fort_weapon_componentto trigger weapon logic when players equip or unequip the custom weapon.Check
IsHolsteredto see if a custom weapon is already in the character’s hands, or use theHolsterChangedEventto listen for when the weapon is equipped or unequipped.Use Verse events
IsHolsteredandHolsterChangedEventto authorize or unauthorize other components (particles or lights) based on whether the weapon is holstered or unholstered.
Modify Custom Weapons at Runtime
Below is example code for a custom weapon device that doubles the damage of any custom weapons in the activating agent’s inventory for an editable duration. Create a Verse device and copy the code below to modify a custom weapon.
Custom weapons always have a fort_trace_weapon_component, or a subclass of the component.
# Copyright Epic Games, Inc. All Rights Reserved.
using { /Fortnite.com/Armory }
using { /Fortnite.com/Devices }
using { /Verse.org/SceneGraph }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Itemization }
To test the Verse device, do the following:
Place an instance of your custom weapon in the scene where you can pick it up.
Copy the above code into a new verse file.
Name the file
double_damage_deviceand save.Select the Compile Verse button in the editor toolbar.
Drag an instance of the Verse device from the content browser into your level.
Drag the Button Device into your level.
Select the instance of your new device in the level and set the
ActivationButtonfield to reference the Button device you added.Select Launch a Session in the editor toolbar to test the device.
Now your custom weapon can do double the damage during the specified time.