๐ซ Weapon
Weapons are entities with firing, reloading and aiming functionalities.
They are fully customizable, all pieces of the weapon can be changed with immense possibility of creation.

๐ย Examplesโ
-- Spawning a Weapon with an AK47 model
local new_weapon = Weapon(
Vector(-900, 185, 215),
Rotator(0, 0, 0),
"nanos-world::SK_AK47"
)
-- Configures Weapon Base Settings
new_weapon:SetAmmoSettings(30, 1000)
new_weapon:SetDamage(30)
new_weapon:SetSpread(30)
new_weapon:SetRecoil(0.25)
new_weapon:SetBulletSettings(1, 20000, 20000, Color(100, 58, 0))
new_weapon:SetCadence(0.1)
new_weapon:SetWallbangSettings(50, 0.75)
-- Configures how the Character Grabs and Aims the Weapon
new_weapon:SetHandlingMode(HandlingMode.DoubleHandedWeapon)
new_weapon:SetSightTransform(Vector(0, 0, -1), Rotator(-1.5, 0, 0))
new_weapon:SetLeftHandTransform(Vector(22, 0, 9), Rotator(0, 60, 90))
new_weapon:SetRightHandOffset(Vector(-10, 0, 0))
-- Configures Weapon Particles
new_weapon:SetParticlesBulletTrail("nanos-world::P_Bullet_Trail")
new_weapon:SetParticlesBarrel("nanos-world::P_Weapon_BarrelSmoke")
new_weapon:SetParticlesShells("nanos-world::P_Weapon_Shells_762x39")
-- Configures Weapon Sounds
new_weapon:SetSoundDry("nanos-world::A_Rifle_Dry")
new_weapon:SetSoundLoad("nanos-world::A_Rifle_Load")
new_weapon:SetSoundUnload("nanos-world::A_Rifle_Unload")
new_weapon:SetSoundZooming("nanos-world::A_AimZoom")
new_weapon:SetSoundAim("nanos-world::A_Rattle")
new_weapon:SetSoundFire("nanos-world::A_AK47_Shot")
-- Configures Weapon Animations
new_weapon:SetAnimationFire("nanos-world::A_AK47_Fire")
new_weapon:SetAnimationCharacterFire("nanos-world::AM_Mannequin_Sight_Fire")
new_weapon:SetAnimationReload("nanos-world::AM_Mannequin_Reload_Rifle")
-- Configures the Mesh to drop when reloading
new_weapon:SetMagazineMesh("nanos-world::SM_AK47_Mag_Empty")
-- Configures the Crosshair Material
new_weapon:SetCrosshairMaterial("nanos-world::MI_Crosshair_Regular")
Using the default-weapons Package to spawn an AK47. First add it to the packages_requirements of your Package.toml:
[script]
# ...
packages_requirements = [
"default-weapons",
]
-- Spawning the AK47 from default-weapons package
local my_ak47 = AK47(Vector(200, 0, 100), Rotator())
-- Giving the Weapon to a Character
my_character:PickUp(my_ak47)
More related examples:
Prop Shootergetting-started/tutorials-and-examples/prop-shooter Weapon Scopegetting-started/tutorials-and-examples/weapon-scope Weapon Flashlightgetting-started/tutorials-and-examples/weapon-flashlight๐ ย Constructorsโ
Default Constructorโ
No description provided
local my_weapon = Weapon(location, rotation, asset, collision_type?, gravity_enabled?, spawn_mode?)
Parameters
| Type | Name | Default | Description |
|---|---|---|---|
| Vector | location | Required parameter | World location to spawn at |
| Rotator | rotation | Required parameter | World rotation to spawn with |
| SkeletalMesh Reference | asset | Required parameter | The asset to use |
| CollisionType | collision_type | CollisionType.Auto | Collision profile of this Actor |
| boolean | gravity_enabled | true | Whether gravity affects this Actor |
| SpawnMode | spawn_mode | SpawnMode.Immediate | Pass SpawnMode.AfterConstructor or SpawnMode.Manual to avoid immediately sending the entity to clients and improve performance when you want to configure it by setting several configs. Must call FinishSpawn() after all |
๐ฟย Static Functionsโ
Inherited Entity Static Functions
Base Entityscripting-reference/classes/base-classes/entity
| Returns | Name | Description | |
|---|---|---|---|
| table of Base Entity | GetAll | Returns a table containing all Entities of the class this is called on | |
| Base Entity | GetByIndex | Returns a specific Entity of this class at an index | |
| integer | GetCount | Returns how many Entities of this class exist | |
| table of table | GetInheritedClasses | Gets a list of all directly inherited classes from this Class created with the Inheriting System | |
| iterator | GetPairs | Returns an iterator with all Entities of this class to be used with pairs() | |
| table or nil | GetParentClass | Gets the parent class if this Class was created with the Inheriting System | |
| table | Inherit | Inherits this class with the Inheriting System | |
| boolean | IsChildOf | Gets if this Class is child of another class if this Class was created with the Inheriting System | |
| function | Subscribe | Subscribes to an Event for all entities of this Class | |
| function | SubscribeRemote | Subscribes to a custom event called from server | |
Unsubscribe | Unsubscribes all callbacks from this Event in this Class within this Package, or only the callback passed |
This class doesn't have own static functions.
๐ฆ ย Functionsโ
Inherited Entity Functions
Base Entityscripting-reference/classes/base-classes/entity
| Returns | Name | Description | |
|---|---|---|---|
BroadcastRemoteEvent | Calls a custom remote event directly on this entity to all Players | ||
BroadcastRemoteInRadiusEvent | Calls a custom remote event directly on this entity to all Players in a radius | ||
CallRemoteEvent | Calls a custom remote event directly on this entity to a specific Player | ||
CallRemoteEvent | Calls a custom remote event directly on this entity | ||
CallRemotePlayersEvent | Calls a custom remote event directly on this entity to a list of Players | ||
Destroy | Destroys this Entity | ||
FinishSpawn | Finish the spawning process and send the entity to clients if it was spawned with a deferred spawn_mode | ||
| table of string | GetAllValuesKeys | Gets a list of all values keys | |
| table | GetClass | Gets the class of this entity | |
| integer | GetID | Gets the universal network ID of this Entity (same on both client and server) | |
| any | GetValue | Gets a Value stored on this Entity at the given key | |
| boolean | HasAuthority | Gets if the local context has authority over this Entity (true if spawned by the client, false if spawned by the server) | |
| boolean | IsA | Recursively checks if this entity is inherited from a Class | |
| boolean | IsBeingDestroyed | Returns true if this Entity is being destroyed | |
| boolean | IsSpawned | Gets if this Entity finished spawning | |
| boolean | IsValid | Returns true if this Entity is valid (i.e. wasn't destroyed and points to a valid Entity) | |
SetSpawnMode | Overrides when this Entity finishes spawning, from the Constructor of an Inherited Class | ||
SetValue | Sets a Value in this Entity | ||
| function | Subscribe | Subscribes to an Event on this specific entity | |
| function | SubscribeRemote | Subscribes to a custom event called from server on this specific entity | |
Unsubscribe | Unsubscribes all callbacks from this Event in this Entity within this Package, or only the callback passed |
Inherited Actor Functions
Base Actorscripting-reference/classes/base-classes/actor
| Returns | Name | Description | |
|---|---|---|---|
AddActorTag | Adds an Unreal Actor Tag to this Actor | ||
AddAngularImpulse | Add an angular impulse to this Actor. Good for one time instant burst | ||
AddImpulse | Add an impulse to this Actor. Good for one time instant burst | ||
| boolean | AttachTo | Attaches this Actor to any other Actor, optionally at a specific bone | |
Detach | Detaches this Actor from AttachedTo Actor | ||
| table of string | GetActorTags | Gets all Unreal Actor Tags on this Actor | |
| Vector | GetAngularForce | Gets this Actor's angular force (set by SetAngularForce()) | |
| float | GetAngularVelocity | Returns the angular velocity of this Actor | |
| table of Base Actor | GetAttachedEntities | Gets all Actors attached to this Actor | |
| Base Actor or nil | GetAttachedTo | Gets the Actor this Actor is attached to | |
| string | GetAttachedToSocket | Gets the bone or socket name this Actor is attached to | |
| table | GetBounds | Gets this Actor's bounds, useful to know its size in the world | |
| CollisionType | GetCollision | Gets this Actor's collision type | |
| integer | GetDimension | Gets this Actor's dimension | |
| float | GetDistanceFromCamera | Gets the distance of this Actor from the Camera | |
| Vector | GetForce | Gets this Actor's force (set by SetForce()) | |
| float | GetLifeSpan | Gets the time (in seconds) left before this Actor is destroyed | |
| Vector | GetLocation | Gets this Actor's location in the game world | |
| float | GetMass | Returns the mass of this Actor | |
| Player or nil | GetNetworkAuthority | Gets this Actor's Network Authority Player | |
| Vector | GetRelativeLocation | Gets this Actor's Relative Location if it's attached | |
| Rotator | GetRelativeRotation | Gets this Actor's Relative Rotation if it's attached | |
| Rotator | GetRotation | Gets this Actor's angle in the game world | |
| Vector | GetScale | Gets this Actor's scale | |
| float | GetScreenPercentage | Gets the percentage of this Actor size in the screen | |
| table | GetSocketTransform | Gets a Socket Transform in world space given a bone or socket name | |
| Vector | GetVelocity | Gets this Actor's current velocity | |
| boolean | HasNetworkAuthority | Returns true if the local Player is currently the Network Authority of this Actor | |
| boolean | IsGravityEnabled | Returns true if gravity is enabled on this Actor | |
| boolean | IsInWater | Returns true if this Actor is in water | |
| boolean | IsNetworkDistributed | Returns true if this Actor is currently network distributed | |
| boolean | IsVisible | Returns true if this Actor is visible | |
RemoveActorTag | Removes an Unreal Actor Tag from this Actor | ||
RotateTo | Smoothly rotates this actor to an angle over a certain time | ||
SetAngularForce | Adds a permanent angular force to this Actor, set to Vector(0, 0, 0) to cancel | ||
SetCastShadow | Sets this Actor's to cast shadows or not | ||
SetCollision | Sets this Actor's collision type | ||
SetDimension | Sets this Actor's Dimension. Actors only see and interact with entities in the same Dimension | ||
SetDistanceOptimizationMultiplier | Sets this Actor's distance optimization multiplier | ||
SetForce | Adds a permanent force to this Actor, set to Vector(0, 0, 0) to cancel | ||
SetGravityEnabled | Sets whether gravity is enabled on this Actor | ||
SetHighlightEnabled | Sets whether the highlight is enabled on this Actor, and which highlight index to use | ||
SetLifeSpan | Sets the time (in seconds) before this Actor is destroyed. After this time has passed, the actor will be automatically destroyed. | ||
SetLocation | Sets this Actor's location in the game world | ||
SetNetworkAuthority | Sets the Player to have network authority over this Actor | ||
SetNetworkAuthorityAutoDistributed | Sets if this Actor will auto distribute the network authority between players | ||
SetOutlineEnabled | Sets whether the outline is enabled on this Actor, and which outline index to use | ||
SetRelativeLocation | Sets this Actor's relative location in local space (only if this actor is attached) | ||
SetRelativeRotation | Sets this Actor's relative rotation in local space (only if this actor is attached) | ||
SetRenderCullDistance | Sets this Actor's render cull distance | ||
SetRotation | Sets this Actor's rotation in the game world | ||
SetScale | Sets this Actor's scale | ||
SetVisibility | Sets whether the actor is visible or not | ||
TranslateTo | Smoothly moves this actor to a location over a certain time | ||
| boolean | WasRecentlyRendered | Gets if this Actor was recently rendered on screen |
Inherited Paintable Functions
Base Paintablescripting-reference/classes/base-classes/paintable
| Returns | Name | Description | |
|---|---|---|---|
| Color | GetMaterialColorParameter | Gets a Color parameter from this Actor's material | |
| float | GetMaterialScalarParameter | Gets a Scalar parameter from this Actor's material | |
| string | GetMaterialTextureParameter | Gets a Texture parameter from this Actor's material | |
| Vector | GetMaterialVectorParameter | Gets a Vector parameter from this Actor's material | |
ResetMaterial | Resets the material from the specified index to the original one | ||
SetMaterial | Sets the material at the specified index of this Actor | ||
SetMaterialColorParameter | Sets a Color parameter in this Actor's material | ||
SetMaterialFromCanvas | Sets the material at the specified index of this Actor to a Canvas object | ||
SetMaterialFromSceneCapture | Sets the material at the specified index of this Actor to a SceneCapture object | ||
SetMaterialFromWebUI | Sets the material at the specified index of this Actor to a WebUI object | ||
SetMaterialScalarParameter | Sets a Scalar parameter in this Actor's material | ||
SetMaterialTextureParameter | Sets a texture parameter in this Actor's material to an image | ||
SetMaterialVectorParameter | Sets a Vector parameter in this Actor's material | ||
SetPhysicalMaterial | Overrides this Actor's Physical Material with a new one |
Inherited Pickable Functions
Base Pickablescripting-reference/classes/base-classes/pickable
| Returns | Name | Description | |
|---|---|---|---|
AddSkeletalMeshAttached | Attaches a Skeletal Mesh as master pose to this entity | ||
AddStaticMeshAttached | Attaches a Static Mesh to this entity | ||
| table of string | GetAllSkeletalMeshAttached | Gets all Skeletal Meshes attached to this entity | |
| table of string | GetAllStaticMeshAttached | Gets all Static Meshes attached to this entity | |
| Character or nil | GetHandler | Gets the Character, if it exists, that's holding this Pickable | |
| HandlingMode | GetHandlingMode | Gets the Handling Mode of this Pickable | |
| SkeletalMesh Reference | GetMesh | Gets the name of the asset this Pickable uses | |
PullUse | Pulls the usage of this Pickable (will start firing if this is a weapon) | ||
ReleaseUse | Releases the usage of this Pickable (will stop firing if this is a weapon) | ||
RemoveAllSkeletalMeshesAttached | Removes all SkeletalMeshes attached | ||
RemoveAllStaticMeshesAttached | Removes all StaticMeshes attached | ||
RemoveSkeletalMeshAttached | Removes, if it exists, a SkeletalMesh from this Pickable given its custom ID | ||
RemoveStaticMeshAttached | Removes, if it exists, a StaticMesh from this Pickable given its custom ID | ||
SetAttachmentSettings | Sets the Attachment Settings for this Pickable (how it attaches to the Character when Picking up) | ||
SetBuoyancyPontoons | Sets the Buoyancy Pontoons used by the Water simulation | ||
SetBuoyancySettings | Sets how this entity behaves on Water | ||
SetCanUse | Sets if this Pickable can be used by the player when held | ||
SetCrosshairMaterial | Sets the crosshair material for this Pickable | ||
SetPickable | Sets if this Pickable can be picked up from ground by the player | ||
SetStaticMeshAttachedTransform | Sets a Static Mesh Attached location and rotation |
| Returns | Name | Description | |
|---|---|---|---|
| integer | GetAmmoBag | Gets this Weapon's Ammo Bag | |
| integer | GetAmmoClip | Gets this Weapon's Ammo Clip | |
| integer | GetAmmoToReload | Gets the amount of ammo needed to fully reload | |
| Animation Reference | GetAnimationCharacterFire | Gets the Animation played by the Character when firing | |
| Animation Reference | GetAnimationFire | Gets the Animation played by the Weapon when firing | |
| Animation Reference | GetAnimationReload | Gets the reload animation | |
| Color | GetBulletColor | Gets the color of the bullet trail | |
| integer | GetBulletCount | Gets how many bullets are fired per shot | |
| float | GetCadence | Gets the time between shots | |
| boolean | GetCanHoldUse | Gets if the weapon can be used continuously by holding the use button | |
| integer | GetClipCapacity | Gets the max number of bullets the clip can hold | |
| integer | GetDamage | Gets the base damage of this Weapon | |
| boolean | GetHoldReleaseUse | Gets if the weapon is triggered/fired when releasing the use button | |
| Vector | GetLeftHandLocation | Gets the location offset of the left hand | |
| Rotator | GetLeftHandRotation | Gets the rotation offset of the left hand | |
| StaticMesh Reference | GetMagazineMesh | Gets the magazine Static Mesh used when reloading | |
| Particle Reference | GetParticlesBarrel | Gets the Particle of the Fire Blast in the muzzle | |
| Particle Reference | GetParticlesBulletTrail | Gets the Particle of the bullet trail | |
| Particle Reference | GetParticlesShells | Gets the Particle of the ejected shells | |
| float | GetRecoil | Gets the base recoil of this Weapon | |
| Vector | GetRightHandOffset | Gets the offset of the right hand, relative to the camera | |
| float | GetSightFOVMultiplier | Gets the Field of View multiplier applied when aiming down sights | |
| Vector | GetSightLocation | Gets the sight location offset used when aiming down sights | |
| Rotator | GetSightRotation | Gets the sight rotation used when aiming down sights | |
| Sound Reference | GetSoundAim | Gets the Sound played when aiming | |
| Sound Reference | GetSoundDry | Gets the Sound played when firing with an empty clip | |
| Sound Reference | GetSoundFire | Gets the Sound played when firing | |
| Sound Reference | GetSoundLoad | Gets the Sound played when loading a magazine | |
| Sound Reference | GetSoundUnload | Gets the Sound played when unloading a magazine | |
| Sound Reference | GetSoundZooming | Gets the Sound played when zooming | |
| float | GetSpread | Gets the base spread of this Weapon | |
| float | GetWallbangDamageMultiplier | Gets the damage multiplier applied when a bullet passes through a wall | |
| float | GetWallbangMaxDistance | Gets the max distance a bullet can pass through walls | |
PlayAnimation | Plays an Animation on this Weapon | ||
Reload | Forces this Weapon to reload | ||
SetAmmoBag | Sets this Weapon's Ammo in the Bag | ||
SetAmmoClip | Sets this Weapon's Ammo in the Clip | ||
SetAmmoSettings | Sets the ammo counts and the clip capacity at once | ||
SetAnimationCharacterFire | Sets the Animation played by the Character when firing this Weapon | ||
SetAnimationFire | Sets the Animation played by the Weapon itself when firing | ||
SetAnimationReload | Sets the Animation played by the Character when reloading this Weapon | ||
SetAutoReload | Sets if the Character will reload automatically when the clip is empty | ||
SetBulletColor | Set the Bullet Color | ||
SetBulletSettings | Sets how many bullets are fired per shot and how they look and travel | ||
SetCadence | Sets the time between shots | ||
SetClipCapacity | Sets the max number of bullets the Weapon's clip can hold | ||
SetDamage | Set the Base Weapon's Damage | ||
SetHandlingMode | Sets how the Character grabs this Weapon | ||
SetLeftHandTransform | Sets where the Character's left hand holds this Weapon, relative to the Weapon | ||
SetMagazineMesh | Set the mesh used when the Character reloads the weapon | ||
SetParticlesBarrel | Sets the Particle of the fire blast at the muzzle | ||
SetParticlesBulletTrail | Sets the Particle of the bullet trail | ||
SetParticlesShells | Sets the Particle of the empty shells ejected when firing | ||
SetRecoil | Sets the base recoil of this Weapon | ||
SetRightHandOffset | Set the offset of Right Hand | ||
SetSightFOVMultiplier | Sets the Field of View multiplier applied when aiming down sights | ||
SetSightTransform | Sets the offset that aligns the Player's view with the Weapon's sight when aiming down sights | ||
SetSoundAim | Sets the Sound played when starting to aim | ||
SetSoundDry | Sets the Sound played when trying to fire with an empty clip | ||
SetSoundFire | Sets the Sound played when firing | ||
SetSoundFireLastBullets | Sound when firing with only having X remaining bullets in the magazine | ||
SetSoundLoad | Sets the Sound played when loading a magazine | ||
SetSoundUnload | Sets the Sound played when unloading a magazine | ||
SetSoundZooming | Sets the Sound played when zooming | ||
SetSpread | Sets the base spread of this Weapon | ||
SetUsageSettings | Sets if the Weapon can hold to keep firing and if it needs to release to fire | ||
SetWallbangSettings | Sets how the bullet will pass through walls | ||
StopAnimation | Stops an Animation Montage on this Weapon |
Optimal

GetAmmoBagโ
Gets this Weapon's Ammo Bag
local ammo_bag = my_weapon:GetAmmoBag()
Returns
| Type | Description |
|---|---|
| integer | This Weapon's Ammo Bag |
See also SetAmmoBag.
Optimal

GetAmmoClipโ
Gets this Weapon's Ammo Clip
local ammo_clip = my_weapon:GetAmmoClip()
Returns
| Type | Description |
|---|---|
| integer | This Weapon's Ammo Clip |
See also SetAmmoClip.
Slow

GetAmmoToReloadโ
Gets the amount of ammo needed to fully reload
local ammo_to_reload = my_weapon:GetAmmoToReload()
Returns
| Type | Description |
|---|---|
| integer | Amount of ammo needed to fully reload |
Optimal

GetAnimationCharacterFireโ
Gets the Animation played by the Character when firing
local animation_character_fire_path = my_weapon:GetAnimationCharacterFire()
Returns
| Type | Description |
|---|---|
| Animation Reference | The Animation asset |
See also SetAnimationCharacterFire.
Optimal

GetAnimationFireโ
Gets the Animation played by the Weapon when firing
local animation_fire_path = my_weapon:GetAnimationFire()
Returns
| Type | Description |
|---|---|
| Animation Reference | The Animation asset |
See also SetAnimationFire.
Optimal

GetAnimationReloadโ
Gets the reload animation
local reload_animation_path = my_weapon:GetAnimationReload()
Returns
| Type | Description |
|---|---|
| Animation Reference | Reload animation |
See also SetAnimationReload.
Optimal

GetBulletColorโ
Gets the color of the bullet trail
local bullet_color = my_weapon:GetBulletColor()
Returns
| Type | Description |
|---|---|
| Color | The bullet trail color |
See also SetBulletColor.
Optimal

GetBulletCountโ
Gets how many bullets are fired per shot
local bullet_count = my_weapon:GetBulletCount()
Returns
| Type | Description |
|---|---|
| integer | Bullets per shot |
Optimal

GetCadenceโ
Gets the time between shots
local cadence = my_weapon:GetCadence()
Returns
| Type | Description |
|---|---|
| float | Seconds between shots |
See also SetCadence.
Optimal

GetCanHoldUseโ
Gets if the weapon can be used continuously by holding the use button
local can_hold_use = my_weapon:GetCanHoldUse()
Returns
| Type | Description |
|---|---|
| boolean | Whether the weapon can be used continuously by holding the use button |
Optimal

GetClipCapacityโ
Gets the max number of bullets the clip can hold
local clip = my_weapon:GetClipCapacity()
Returns
| Type | Description |
|---|---|
| integer | The clip capacity |
See also SetClipCapacity.
Optimal

GetDamageโ
Gets the base damage of this Weapon
local damage = my_weapon:GetDamage()
Returns
| Type | Description |
|---|---|
| integer | The base damage |
See also SetDamage.
Optimal

GetHoldReleaseUseโ
Gets if the weapon is triggered/fired when releasing the use button
local hold_release_use = my_weapon:GetHoldReleaseUse()
Returns
| Type | Description |
|---|---|
| boolean | Whether the weapon is triggered/fired when releasing the use button |
Optimal

GetLeftHandLocationโ
Gets the location offset of the left hand
local left_hand_location = my_weapon:GetLeftHandLocation()
Returns
| Type | Description |
|---|---|
| Vector | The left hand location offset |
Optimal

GetLeftHandRotationโ
Gets the rotation offset of the left hand
local left_hand_rotation = my_weapon:GetLeftHandRotation()
Returns
| Type | Description |
|---|---|
| Rotator | The left hand rotation offset |
Optimal

GetMagazineMeshโ
Gets the magazine Static Mesh used when reloading
local magazine_mesh = my_weapon:GetMagazineMesh()
Returns
| Type | Description |
|---|---|
| StaticMesh Reference | The Static Mesh asset |
See also SetMagazineMesh.
Optimal

GetParticlesBarrelโ
Gets the Particle of the Fire Blast in the muzzle
local particle_asset_path = my_weapon:GetParticlesBarrel()
Returns
| Type | Description |
|---|---|
| Particle Reference | Particle of the Fire Blast in the muzzle |
See also SetParticlesBarrel.
Optimal

GetParticlesBulletTrailโ
Gets the Particle of the bullet trail
local particle_bullet_trail_asset_path = my_weapon:GetParticlesBulletTrail()
Returns
| Type | Description |
|---|---|
| Particle Reference | The Particle asset |
See also SetParticlesBulletTrail.
Optimal

GetParticlesShellsโ
Gets the Particle of the ejected shells
local particle_shells_asset_path = my_weapon:GetParticlesShells()
Returns
| Type | Description |
|---|---|
| Particle Reference | The Particle asset |
See also SetParticlesShells.
Optimal

GetRecoilโ
Gets the base recoil of this Weapon
local recoil = my_weapon:GetRecoil()
Returns
| Type | Description |
|---|---|
| float | The base recoil, 0 means no recoil |
See also SetRecoil.
Optimal

GetRightHandOffsetโ
Gets the offset of the right hand, relative to the camera
local right_hand_offset = my_weapon:GetRightHandOffset()
Returns
| Type | Description |
|---|---|
| Vector | The right hand offset |
See also SetRightHandOffset.
Optimal

GetSightFOVMultiplierโ
Gets the Field of View multiplier applied when aiming down sights
local sight_fov_multiplier = my_weapon:GetSightFOVMultiplier()
Returns
| Type | Description |
|---|---|
| float | The FOV multiplier |
See also SetSightFOVMultiplier.
Optimal

GetSightLocationโ
Gets the sight location offset used when aiming down sights
local sight_location = my_weapon:GetSightLocation()
Returns
| Type | Description |
|---|---|
| Vector | The sight location offset |
Optimal

GetSightRotationโ
Gets the sight rotation used when aiming down sights
local sight_rotation = my_weapon:GetSightRotation()
Returns
| Type | Description |
|---|---|
| Rotator | The sight rotation |
Optimal

GetSoundAimโ
Gets the Sound played when aiming
local sound_aim_asset_path = my_weapon:GetSoundAim()
Returns
| Type | Description |
|---|---|
| Sound Reference | The Sound asset |
See also SetSoundAim.
Optimal

GetSoundDryโ
Gets the Sound played when firing with an empty clip
local sound_dry_asset_path = my_weapon:GetSoundDry()
Returns
| Type | Description |
|---|---|
| Sound Reference | The Sound asset |
See also SetSoundDry.
Optimal

GetSoundFireโ
Gets the Sound played when firing
local sound_fire_asset_path = my_weapon:GetSoundFire()
Returns
| Type | Description |
|---|---|
| Sound Reference | The Sound asset |
See also SetSoundFire.
Slow

GetSoundLoadโ
Gets the Sound played when loading a magazine
local sound_load_asset_path = my_weapon:GetSoundLoad()
Returns
| Type | Description |
|---|---|
| Sound Reference | The Sound asset |
See also SetSoundLoad.
Slow

GetSoundUnloadโ
Gets the Sound played when unloading a magazine
local sound_unload_asset_path = my_weapon:GetSoundUnload()
Returns
| Type | Description |
|---|---|
| Sound Reference | The Sound asset |
See also SetSoundUnload.
Optimal

GetSoundZoomingโ
Gets the Sound played when zooming
local sound_zooming_asset_path = my_weapon:GetSoundZooming()
Returns
| Type | Description |
|---|---|
| Sound Reference | The Sound asset |
See also SetSoundZooming.
Optimal

GetSpreadโ
Gets the base spread of this Weapon
local spread = my_weapon:GetSpread()
Returns
| Type | Description |
|---|---|
| float | The base spread, higher means less precision |
See also SetSpread.
Optimal

GetWallbangDamageMultiplierโ
Gets the damage multiplier applied when a bullet passes through a wall
local damage_multiplier = my_weapon:GetWallbangDamageMultiplier()
Returns
| Type | Description |
|---|---|
| float | Damage multiplier applied when a bullet passes through a wall |
Optimal

GetWallbangMaxDistanceโ
Gets the max distance a bullet can pass through walls
local max_distance = my_weapon:GetWallbangMaxDistance()
Returns
| Type | Description |
|---|---|
| float | Max distance a bullet can pass through walls |
Slow

PlayAnimationโ
Plays an Animation on this Weapon
my_weapon:PlayAnimation(animation_path, slot_name?, loop_indefinitely?, blend_in_time?, blend_out_time?, play_rate?, stop_all_montages?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Animation Reference | animation_path | Required parameter | The Animation asset to play |
| string | slot_name? | DefaultSlot | The Animation Slot to play it on |
| boolean | loop_indefinitely? | false | This parameter is only used if the Weapon has an Animation Blueprint |
| float | blend_in_time? | 0.25 | This parameter is only used if the Weapon has an Animation Blueprint |
| float | blend_out_time? | 0.25 | This parameter is only used if the Weapon has an Animation Blueprint |
| float | play_rate? | 1.0 | This parameter is only used if the Weapon has an Animation Blueprint |
| boolean | stop_all_montages? | false | Stops all running Montages from the same Group. This parameter is only used if the Weapon has an Animation Blueprint |
Moderate

Reloadโ
Forces this Weapon to reload (only if being handled by a Character)
my_weapon:Reload()
Optimal

SetAmmoBagโ
Sets this Weapon's Ammo in the Bag
my_weapon:SetAmmoBag(new_ammo_bag)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| integer | new_ammo_bag | Required parameter | The new Ammo in the Bag |
See also GetAmmoBag.
Optimal

SetAmmoClipโ
Sets this Weapon's Ammo in the Clip
my_weapon:SetAmmoClip(new_ammo_clip)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| integer | new_ammo_clip | Required parameter | The new Ammo in the Clip |
See also GetAmmoClip.
Optimal

SetAmmoSettingsโ
Sets the ammo counts and the clip capacity at once
my_weapon:SetAmmoSettings(ammo_clip, ammo_bag, ammo_to_reload?, clip_capacity?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| integer | ammo_clip | Required parameter | Bullets currently loaded in the clip |
| integer | ammo_bag | Required parameter | Spare bullets carried, used when reloading |
| integer | ammo_to_reload? | ammo_clip | Bullets loaded on each reload, useful for shotguns that load one shell at a time. Defaults to the clip capacity |
| integer | clip_capacity? | ammo_clip | Max bullets the clip can hold |
Slow

SetAnimationCharacterFireโ
Sets the Animation played by the Character when firing this Weapon
my_weapon:SetAnimationCharacterFire(animation_character_fire_path, play_rate?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Animation Reference | animation_character_fire_path | Required parameter | The Animation asset to play on the Character |
| float | play_rate? | 1 | Speed multiplier of the animation |
See also GetAnimationCharacterFire.
Slow

SetAnimationFireโ
Sets the Animation played by the Weapon itself when firing
my_weapon:SetAnimationFire(animation_fire_path, play_rate?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Animation Reference | animation_fire_path | Required parameter | The Animation asset to play on the Weapon mesh |
| float | play_rate? | 1 | Speed multiplier of the animation |
See also GetAnimationFire.
Slow

SetAnimationReloadโ
Sets the Animation played by the Character when reloading this Weapon
my_weapon:SetAnimationReload(reload_animation_path, play_rate?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Animation Reference | reload_animation_path | Required parameter | The Animation asset to play on the Character |
| float | play_rate? | 1 | Speed multiplier of the animation |
See also GetAnimationReload.
Optimal

SetAutoReloadโ
If the Character will reload automatically when ammo empties. Default is true
my_weapon:SetAutoReload(auto_reload)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| boolean | auto_reload | Required parameter | Whether to reload automatically |
Optimal

SetBulletColorโ
Set the Bullet Color
Only has effect if using Bullet Trail particle P_Bullet_Trail or if you particle has the Color parameter
my_weapon:SetBulletColor(bullet_color)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Color | bullet_color | Required parameter | The new Bullet Color |
See also GetBulletColor.
Optimal

SetBulletSettingsโ
Sets how many bullets are fired per shot and how they look and travel
my_weapon:SetBulletSettings(bullet_count, bullet_max_distance, bullet_velocity, bullet_color)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| integer | bullet_count | Required parameter | 1 for common weapons > 1 for shotguns |
| integer | bullet_max_distance | Required parameter | Max distance the bullet travels (in units, 1 unit = 1 cm) |
| integer | bullet_velocity | Required parameter | Visuals only |
| Color | bullet_color | Required parameter | Color of the bullet trail |
Optimal

SetCadenceโ
Sets the time between shots
my_weapon:SetCadence(cadence)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| float | cadence | Required parameter | 1 shot at each cadence second |
See also GetCadence.
Optimal

SetClipCapacityโ
Sets the max number of bullets the Weapon's clip can hold
my_weapon:SetClipCapacity(clip)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| integer | clip | Required parameter | The new clip capacity |
See also GetClipCapacity.
Optimal

SetDamageโ
Base Weapon's Damage
This will be multiplied by multiplier factors when hitting specific bones
my_weapon:SetDamage(damage)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| integer | damage | Required parameter | The new Base Weapon's Damage |
See also GetDamage.
Optimal

SetHandlingModeโ
Sets how the Character grabs this Weapon
my_weapon:SetHandlingMode(handling_mode)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| HandlingMode | handling_mode | Required parameter | The new how the Character grabs this Weapon |
Optimal

SetLeftHandTransformโ
Sets where the Character's left hand holds this Weapon, relative to the Weapon
my_weapon:SetLeftHandTransform(left_hand_location, left_hand_rotation)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Vector | left_hand_location | Required parameter | Location offset of the left hand |
| Rotator | left_hand_rotation | Required parameter | Rotation offset of the left hand |
Slow

SetMagazineMeshโ
Set the mesh used when the Character reloads the weapon.
Will drop this Mesh as an animation effect.
my_weapon:SetMagazineMesh(magazine_mesh, magazine_mesh_hide_bone?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| StaticMesh Reference | magazine_mesh | Required parameter | The Static Mesh of the magazine, spawned in the Character's hand during the reload |
| string | magazine_mesh_hide_bone? | b_gun_mag | Weapon bone to hide when reloading it |
See also GetMagazineMesh.
Slow

SetParticlesBarrelโ
Sets the Particle of the fire blast at the muzzle
my_weapon:SetParticlesBarrel(particle_asset_path)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Particle Reference | particle_asset_path | Required parameter | The Particle asset to spawn at the muzzle when firing |
See also GetParticlesBarrel.
Slow

SetParticlesBulletTrailโ
Sets the Particle of the bullet trail
my_weapon:SetParticlesBulletTrail(particle_bullet_trail_asset_path)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Particle Reference | particle_bullet_trail_asset_path | Required parameter | The Particle asset to spawn for each bullet |
See also GetParticlesBulletTrail.
Slow

SetParticlesShellsโ
Sets the Particle of the empty shells ejected when firing
my_weapon:SetParticlesShells(particle_shells_asset_path)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Particle Reference | particle_shells_asset_path | Required parameter | The Particle asset to spawn when ejecting a shell |
See also GetParticlesShells.
Optimal

SetRecoilโ
Sets the base recoil of this Weapon
my_weapon:SetRecoil(recoil)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| float | recoil | Required parameter | 0 means no Recoil, default is 1 |
See also GetRecoil.
Optimal

SetRightHandOffsetโ
Set the Offset of Right Hand. To position relative to the camera.
my_weapon:SetRightHandOffset(right_hand_offset)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Vector | right_hand_offset | Required parameter | The new offset of Right Hand |
See also GetRightHandOffset.
Optimal

SetSightFOVMultiplierโ
Sets the Field of View multiplier applied when aiming down sights
my_weapon:SetSightFOVMultiplier(sight_fov_multiplier)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| float | sight_fov_multiplier | Required parameter | Values below 1 zoom in, for example 0.5 for a scope |
See also GetSightFOVMultiplier.
Optimal

SetSightTransformโ
Sets the offset that aligns the Player's view with the Weapon's sight when aiming down sights
my_weapon:SetSightTransform(sight_location, sight_rotation)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Vector | sight_location | Required parameter | Offset between the camera and the sight |
| Rotator | sight_rotation | Required parameter | Rotation applied to the Weapon while aiming |
Slow

SetSoundAimโ
Sets the Sound played when starting to aim
my_weapon:SetSoundAim(sound_aim_asset_path, volume?, pitch?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Sound Reference | sound_aim_asset_path | Required parameter | The Sound asset to play |
| float | volume? | 1 | Volume multiplier |
| float | pitch? | 1 | Pitch multiplier |
See also GetSoundAim.
Slow

SetSoundDryโ
Sets the Sound played when trying to fire with an empty clip
my_weapon:SetSoundDry(sound_dry_asset_path, volume?, pitch?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Sound Reference | sound_dry_asset_path | Required parameter | The Sound asset to play |
| float | volume? | 1 | Volume multiplier |
| float | pitch? | 1 | Pitch multiplier |
See also GetSoundDry.
Slow

SetSoundFireโ
Sets the Sound played when firing
my_weapon:SetSoundFire(sound_fire_asset_path, volume?, pitch?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Sound Reference | sound_fire_asset_path | Required parameter | The Sound asset to play |
| float | volume? | 1 | Volume multiplier |
| float | pitch? | 1 | Pitch multiplier |
See also GetSoundFire.
Slow

SetSoundFireLastBulletsโ
Sound when firing with only having X remaining bullets in the magazine, useful for last shot 'ping' or sound when low on bullets
my_weapon:SetSoundFireLastBullets(sound_asset_path, remaining_bullets_count?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Sound Reference | sound_asset_path | Required parameter | The Sound asset to play |
| integer | remaining_bullets_count? | 1 | The amount of remaining bullet to start playing this sound |
Slow

SetSoundLoadโ
Sets the Sound played when loading a magazine
my_weapon:SetSoundLoad(sound_load_asset_path, volume?, pitch?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Sound Reference | sound_load_asset_path | Required parameter | The Sound asset to play |
| float | volume? | 1 | Volume multiplier |
| float | pitch? | 1 | Pitch multiplier |
See also GetSoundLoad.
Slow

SetSoundUnloadโ
Sets the Sound played when unloading a magazine
my_weapon:SetSoundUnload(sound_unload_asset_path, volume?, pitch?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Sound Reference | sound_unload_asset_path | Required parameter | The Sound asset to play |
| float | volume? | 1 | Volume multiplier |
| float | pitch? | 1 | Pitch multiplier |
See also GetSoundUnload.
Slow

SetSoundZoomingโ
Sets the Sound played when zooming
my_weapon:SetSoundZooming(sound_zooming_asset_path, volume?, pitch?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Sound Reference | sound_zooming_asset_path | Required parameter | The Sound asset to play |
| float | volume? | 1 | Volume multiplier |
| float | pitch? | 1 | Pitch multiplier |
See also GetSoundZooming.
Optimal

SetSpreadโ
Sets the base spread of this Weapon
my_weapon:SetSpread(spread)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| float | spread | Required parameter | the higher the less precision - recommended value: 20 |
See also GetSpread.
Optimal

SetUsageSettingsโ
Sets if the Weapon can hold to keep firing and if it needs to release to fire
my_weapon:SetUsageSettings(can_hold_use, hold_release_use)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| boolean | can_hold_use | Required parameter | Whether holding the fire button keeps firing (automatic weapons) |
| boolean | hold_release_use | Required parameter | Whether it only fires when the fire button is released (e.g. bows) |
Optimal

SetWallbangSettingsโ
Sets how the bullet will pass through walls
my_weapon:SetWallbangSettings(max_distance, damage_multiplier)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| integer | max_distance | Required parameter | Max distance to pass through another wall |
| float | damage_multiplier | Required parameter | Damage given if wallbangged |
Optimal

StopAnimationโ
Stops an Animation Montage on this Weapon
my_weapon:StopAnimation(animation_asset?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Animation Reference | animation_asset? | | Leave empty to stop all Montages |
๐ย Eventsโ
Inherited Entity Events
Base Entityscripting-reference/classes/base-classes/entity
| Name | Description | |
|---|---|---|
ClassRegister | Triggered when a new Class is registered with the Inheriting System | |
Destroy | Triggered when an Entity is destroyed | |
Spawn | Triggered when an Entity is spawned/created | |
ValueChange | Triggered when an Entity has a value changed with :SetValue() |
Inherited Actor Events
Base Actorscripting-reference/classes/base-classes/actor
| Name | Description | |
|---|---|---|
DimensionChange | Triggered when an Actor changes its dimension | |
EnterWater | Triggered when an Actor enters a water body | |
LeaveWater | Triggered when an Actor leaves a water body | |
NetworkAuthorityChange | Triggered when an Actor changes its network authority Player | |
NetworkAuthorityChange | Triggered when the local Player gets/loses network authority over this actor |
Inherited Pickable Events
Base Pickablescripting-reference/classes/base-classes/pickable
| Name | Description | |
|---|---|---|
Drop | When a Character drops this Pickable | |
Hit | When this Pickable hits something | |
Interact | Triggered when a Character interacts with this Pickable (i.e. tries to pick it up) | |
PickUp | Triggered When a Character picks this up | |
PullUse | Triggered when a Character presses the use button for this Pickable (i.e. clicks left mouse button with this equipped) | |
ReleaseUse | Triggered when a Character releases the use button for this Pickable (i.e. releases left mouse button with this equipped) |
| Name | Description | |
|---|---|---|
AmmoBagChange | When the Ammo Bag is changed, by reloading or manually setting through scripting | |
AmmoClipChange | When the Ammo Clip is changed, by reloading or manually setting through scripting | |
BulletHit | Triggered when bullets hit (this will be triggered for each bullet shot) | |
Fire | Triggered when Weapon fires (this will be triggered for each shot) | |
Reload | When a Weapon is reloaded, optionally by a Character |

AmmoBagChangeโ
When the Ammo Bag is changed, by reloading or manually setting through scripting
Weapon.Subscribe("AmmoBagChange", function(self, old_ammo_bag, new_ammo_bag)
-- AmmoBagChange was called
end)
Arguments
| Type | Argument | Description |
|---|---|---|
| Weapon | self | The Weapon that triggered the event |
| integer | old_ammo_bag | The previous bag ammo |
| integer | new_ammo_bag | The new bag ammo |

AmmoClipChangeโ
When the Ammo Clip is changed, by reloading or manually setting through scripting
Weapon.Subscribe("AmmoClipChange", function(self, old_ammo_clip, new_ammo_clip)
-- AmmoClipChange was called
end)
Arguments
| Type | Argument | Description |
|---|---|---|
| Weapon | self | The Weapon that triggered the event |
| integer | old_ammo_clip | The previous clip ammo |
| integer | new_ammo_clip | The new clip ammo |

BulletHitโ
Triggered when bullets hit (this will be triggered for each bullet shot)
Weapon.Subscribe("BulletHit", function(self, impact_point, impact_normal, damage, actor_hit)
-- BulletHit was called
end)
Arguments
| Type | Argument | Description |
|---|---|---|
| Weapon | self | The Weapon that triggered the event |
| Vector | impact_point | Location in world space of the bullet hit |
| Vector | impact_normal | Normal of the bullet hit in world space |
| integer | damage | Damage that was applied |
| Base Actor or nil | actor_hit | Actor entity that was hit, if any |

Fireโ
Triggered when Weapon fires (this will be triggered for each shot)
Weapon.Subscribe("Fire", function(self, shooter)
-- Fire was called
end)
Arguments
| Type | Argument | Description |
|---|---|---|
| Weapon | self | The Weapon that triggered the event |
| Character | shooter | The Character holding the Weapon, if any |

Reloadโ
When a Weapon is reloaded, optionally by a Character
Weapon.Subscribe("Reload", function(self, character, ammo_to_reload)
-- Reload was called
end)


