๐ซ 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
| Name | Type | Description |
|---|---|---|
location | Vector | World location to spawn at |
rotation | Rotator | World rotation to spawn with |
asset | SkeletalMesh Reference | The asset to use |
collision_type? | CollisionType | Collision profile of this Actor Default CollisionType.Auto |
gravity_enabled? | boolean | Whether gravity affects this Actor Default true |
spawn_mode? | SpawnMode | 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 Default SpawnMode.Immediate |
๐ฟ Static Functionsโ
This class doesn't have own static functions.
Inherited static functions
Subscribe, UnsubscribeSubscribeRemoteGetAll, GetByIndex, GetCount, GetPairs๐ฆ Functionsโ
| Ammunition | ||
GetAmmoBag: integer | Gets this Weapon's Ammo Bag | |
GetAmmoClip: integer | Gets this Weapon's Ammo Clip | |
GetAmmoToReload: integer | Gets the amount of ammo needed to fully reload | |
GetClipCapacity: integer | Gets the max number of bullets the clip can hold | |
Reload: boolean | 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 | |
SetAutoReload | Sets if the Character will reload automatically when the clip is empty | |
SetClipCapacity | Sets the max number of bullets the Weapon's clip can hold | |
| Animation | ||
GetAnimationCharacterFire: Animation Reference | Gets the Animation played by the Character when firing | |
GetAnimationFire: Animation Reference | Gets the Animation played by the Weapon when firing | |
GetAnimationReload: Animation Reference | Gets the reload animation | |
PlayAnimation | Plays an Animation on this Weapon | |
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 | |
StopAnimation | Stops an Animation Montage on this Weapon | |
| Audio | ||
GetSoundAim: Sound Reference | Gets the Sound played when aiming | |
GetSoundDry: Sound Reference | Gets the Sound played when firing with an empty clip | |
GetSoundFire: Sound Reference | Gets the Sound played when firing | |
GetSoundLoad: Sound Reference | Gets the Sound played when loading a magazine | |
GetSoundUnload: Sound Reference | Gets the Sound played when unloading a magazine | |
GetSoundZooming: Sound Reference | Gets the Sound played when zooming | |
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 | |
| Combat | ||
GetBulletCount: integer | Gets how many bullets are fired per shot | |
GetCadence: float | Gets the time between shots | |
GetCanHoldUse: boolean | Gets if the weapon can be used continuously by holding the use button | |
GetDamage: integer | Gets the base damage of this Weapon | |
GetHoldReleaseUse: boolean | Gets if the weapon is triggered/fired when releasing the use button | |
GetSpread: float | Gets the base spread of this Weapon | |
GetWallbangDamageMultiplier: float | Gets the damage multiplier applied when a bullet passes through a wall | |
GetWallbangMaxDistance: float | Gets the max distance a bullet can pass through walls | |
SetBulletSettings | Sets how many bullets are fired per shot and how they look and travel | |
SetCadence | Sets the time between shots | |
SetDamage | Set the Base Weapon's Damage | |
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 | |
| Effects | ||
GetBulletColor: Color | Gets the color of the bullet trail | |
GetMagazineMesh: StaticMesh Reference | Gets the magazine Static Mesh used when reloading | |
GetParticlesBarrel: Particle Reference | Gets the Particle of the Fire Blast in the muzzle | |
GetParticlesBulletTrail: Particle Reference | Gets the Particle of the bullet trail | |
GetParticlesShells: Particle Reference | Gets the Particle of the ejected shells | |
SetBulletColor | Set the Bullet Color | |
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 | |
| Handling | ||
GetLeftHandLocation: Vector | Gets the location offset of the left hand | |
GetLeftHandRotation: Rotator | Gets the rotation offset of the left hand | |
GetRecoil: float | Gets the base recoil of this Weapon | |
GetRightHandOffset: Vector | Gets the offset of the right hand, relative to the camera | |
GetSightFOVMultiplier: float | Gets the Field of View multiplier applied when aiming down sights | |
GetSightLocation: Vector | Gets the sight location offset used when aiming down sights | |
GetSightRotation: Rotator | Gets the sight rotation used when aiming down sights | |
SetHandlingMode | Sets how the Character grabs this Weapon | |
SetLeftHandTransform | Sets where the Character's left hand holds this Weapon, relative to the Weapon | |
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 | |
Inherited functions
GetMesh, SetCrosshairMaterialAddSkeletalMeshAttached, AddStaticMeshAttached, GetAllSkeletalMeshAttached, GetAllStaticMeshAttached, RemoveAllSkeletalMeshesAttached, RemoveAllStaticMeshesAttached, RemoveSkeletalMeshAttached, RemoveStaticMeshAttached, SetStaticMeshAttachedTransformPullUse, ReleaseUse, SetCanUseGetMaterialColorParameter, GetMaterialScalarParameter, GetMaterialTextureParameter, GetMaterialVectorParameter, ResetMaterial, SetMaterial, SetMaterialColorParameter, SetMaterialFromCanvas, SetMaterialFromSceneCapture, SetMaterialFromWebUI, SetMaterialScalarParameter, SetMaterialTextureParameter, SetMaterialVectorParameter, SetPhysicalMaterialGetDistanceFromCamera, GetScreenPercentage, IsVisible, SetCastShadow, SetHighlightEnabled, SetOutlineEnabled, SetRenderCullDistance, SetVisibility, WasRecentlyRenderedAttachTo, Detach, GetAttachedEntities, GetAttachedTo, GetAttachedToSocket, GetSocketTransformGetLifeSpan, SetLifeSpanGetDimension, GetNetworkAuthority, HasNetworkAuthority, IsNetworkDistributed, SetDimension, SetDistanceOptimizationMultiplier, SetNetworkAuthority, SetNetworkAuthorityAutoDistributedGetAllValuesKeys, GetValue, SetValueSubscribe, UnsubscribeDestroy, FinishSpawn, IsBeingDestroyed, IsSpawned, IsValid, SetSpawnModeBroadcastRemoteEvent, BroadcastRemoteInRadiusEvent, CallRemoteEvent, CallRemoteEvent, CallRemotePlayersEvent, HasAuthority, SubscribeRemoteGetIDAmmunitionfunctionsโ

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

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

GetAmmoToReloadSlowโ
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 |

GetClipCapacityOptimalโ
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.

ReloadModerateโ
Forces this Weapon to reload
It only works while a Character is handling the Weapon, the Ammo Bag is not empty and the Clip is not full. Returning true means the reload was requested, it can still be cancelled by the Character's AttemptReload event or interrupted. Use the Reload event to know how many bullets were actually reloaded
local reload_requested = my_weapon:Reload()
Returns
| Type | Description |
|---|---|
| boolean | Whether the reload was requested |

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

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

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

SetAutoReloadOptimalโ
Sets if the Character will reload automatically when the clip is empty
If the Character will reload automatically when ammo empties. Default is true
my_weapon:SetAutoReload(auto_reload)
Parameters
| Name | Type | Description |
|---|---|---|
auto_reload | boolean | Whether to reload automatically |

SetClipCapacityOptimalโ
Sets the max number of bullets the Weapon's clip can hold
my_weapon:SetClipCapacity(clip)
Parameters
| Name | Type | Description |
|---|---|---|
clip | integer | The new clip capacity |
See also GetClipCapacity.
Animationfunctionsโ

GetAnimationCharacterFireOptimalโ
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.

GetAnimationFireOptimalโ
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.

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

PlayAnimationSlowโ
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
| Name | Type | Description |
|---|---|---|
animation_path | Animation Reference | The Animation asset to play |
slot_name? | string | The Animation Slot to play it on Default DefaultSlot |
loop_indefinitely? | boolean | This parameter is only used if the Weapon has an Animation Blueprint Default false |
blend_in_time? | float | This parameter is only used if the Weapon has an Animation Blueprint Default 0.25 |
blend_out_time? | float | This parameter is only used if the Weapon has an Animation Blueprint Default 0.25 |
play_rate? | float | This parameter is only used if the Weapon has an Animation Blueprint Default 1.0 |
stop_all_montages? | boolean | Stops all running Montages from the same Group. This parameter is only used if the Weapon has an Animation Blueprint Default false |

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

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

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

StopAnimationOptimalโ
Stops an Animation Montage on this Weapon
my_weapon:StopAnimation(animation_asset?)
Parameters
| Name | Type | Description |
|---|---|---|
animation_asset? | Animation Reference | Leave empty to stop all Montages Default |
Audiofunctionsโ

GetSoundAimOptimalโ
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.

GetSoundDryOptimalโ
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.

GetSoundFireOptimalโ
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.

GetSoundLoadSlowโ
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.

GetSoundUnloadSlowโ
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.

GetSoundZoomingOptimalโ
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.

SetSoundAimSlowโ
Sets the Sound played when starting to aim
my_weapon:SetSoundAim(sound_aim_asset_path?, volume?, pitch?)
Parameters
| Name | Type | Description |
|---|---|---|
sound_aim_asset_path? | Sound Reference | The Sound asset to play, pass nil or an empty string for no sound Default nil |
volume? | float | Volume multiplier Default 1 |
pitch? | float | Pitch multiplier Default 1 |
See also GetSoundAim.

SetSoundDrySlowโ
Sets the Sound played when trying to fire with an empty clip
my_weapon:SetSoundDry(sound_dry_asset_path?, volume?, pitch?)
Parameters
| Name | Type | Description |
|---|---|---|
sound_dry_asset_path? | Sound Reference | The Sound asset to play, pass nil or an empty string for no sound Default nil |
volume? | float | Volume multiplier Default 1 |
pitch? | float | Pitch multiplier Default 1 |
See also GetSoundDry.

SetSoundFireSlowโ
Sets the Sound played when firing
my_weapon:SetSoundFire(sound_fire_asset_path?, volume?, pitch?)
Parameters
| Name | Type | Description |
|---|---|---|
sound_fire_asset_path? | Sound Reference | The Sound asset to play, pass nil or an empty string for no sound Default nil |
volume? | float | Volume multiplier Default 1 |
pitch? | float | Pitch multiplier Default 1 |
See also GetSoundFire.

SetSoundFireLastBulletsSlowโ
Sound when firing with only having X remaining bullets in the magazine
Useful for a last shot 'ping' or a sound when low on bullets
my_weapon:SetSoundFireLastBullets(sound_asset_path?, remaining_bullets_count?)
Parameters
| Name | Type | Description |
|---|---|---|
sound_asset_path? | Sound Reference | The Sound asset to play, pass nil or an empty string for no sound Default nil |
remaining_bullets_count? | integer | The amount of remaining bullet to start playing this sound Default 1 |

SetSoundLoadSlowโ
Sets the Sound played when loading a magazine
my_weapon:SetSoundLoad(sound_load_asset_path?, volume?, pitch?)
Parameters
| Name | Type | Description |
|---|---|---|
sound_load_asset_path? | Sound Reference | The Sound asset to play, pass nil or an empty string for no sound Default nil |
volume? | float | Volume multiplier Default 1 |
pitch? | float | Pitch multiplier Default 1 |
See also GetSoundLoad.

SetSoundUnloadSlowโ
Sets the Sound played when unloading a magazine
my_weapon:SetSoundUnload(sound_unload_asset_path?, volume?, pitch?)
Parameters
| Name | Type | Description |
|---|---|---|
sound_unload_asset_path? | Sound Reference | The Sound asset to play, pass nil or an empty string for no sound Default nil |
volume? | float | Volume multiplier Default 1 |
pitch? | float | Pitch multiplier Default 1 |
See also GetSoundUnload.

SetSoundZoomingSlowโ
Sets the Sound played when zooming
my_weapon:SetSoundZooming(sound_zooming_asset_path?, volume?, pitch?)
Parameters
| Name | Type | Description |
|---|---|---|
sound_zooming_asset_path? | Sound Reference | The Sound asset to play, pass nil or an empty string for no sound Default nil |
volume? | float | Volume multiplier Default 1 |
pitch? | float | Pitch multiplier Default 1 |
See also GetSoundZooming.
Combatfunctionsโ

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

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

GetCanHoldUseOptimalโ
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 |

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

GetHoldReleaseUseOptimalโ
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 |

GetSpreadOptimalโ
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.

GetWallbangDamageMultiplierOptimalโ
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 |

GetWallbangMaxDistanceOptimalโ
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 |

SetBulletSettingsOptimalโ
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)

SetCadenceOptimalโ
Sets the time between shots
my_weapon:SetCadence(cadence)
Parameters
| Name | Type | Description |
|---|---|---|
cadence | float | 1 shot at each cadence second |
See also GetCadence.

SetDamageOptimalโ
Set the Base Weapon's Damage
Base Weapon's Damage
This will be multiplied by multiplier factors when hitting specific bones
my_weapon:SetDamage(damage)
Parameters
| Name | Type | Description |
|---|---|---|
damage | integer | The new Base Weapon's Damage |
See also GetDamage.

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

SetUsageSettingsOptimalโ
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)

SetWallbangSettingsOptimalโ
Sets how the bullet will pass through walls
my_weapon:SetWallbangSettings(max_distance, damage_multiplier)
Effectsfunctionsโ

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

GetMagazineMeshOptimalโ
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.

GetParticlesBarrelOptimalโ
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.

GetParticlesBulletTrailOptimalโ
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.

GetParticlesShellsOptimalโ
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.

SetBulletColorOptimalโ
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
| Name | Type | Description |
|---|---|---|
bullet_color | Color | The new Bullet Color |
See also GetBulletColor.

SetMagazineMeshSlowโ
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
| Name | Type | Description |
|---|---|---|
magazine_mesh | StaticMesh Reference | The Static Mesh of the magazine, spawned in the Character's hand during the reload |
magazine_mesh_hide_bone? | string | Weapon bone to hide when reloading it Default b_gun_mag |
See also GetMagazineMesh.

SetParticlesBarrelSlowโ
Sets the Particle of the fire blast at the muzzle
my_weapon:SetParticlesBarrel(particle_asset_path?)
Parameters
| Name | Type | Description |
|---|---|---|
particle_asset_path? | Particle Reference | The Particle asset to spawn at the muzzle when firing, pass nil or an empty string for no particle Default nil |
See also GetParticlesBarrel.

SetParticlesBulletTrailSlowโ
Sets the Particle of the bullet trail
my_weapon:SetParticlesBulletTrail(particle_bullet_trail_asset_path?)
Parameters
| Name | Type | Description |
|---|---|---|
particle_bullet_trail_asset_path? | Particle Reference | The Particle asset to spawn for each bullet, pass nil or an empty string for no particle Default nil |
See also GetParticlesBulletTrail.

SetParticlesShellsSlowโ
Sets the Particle of the empty shells ejected when firing
my_weapon:SetParticlesShells(particle_shells_asset_path?)
Parameters
| Name | Type | Description |
|---|---|---|
particle_shells_asset_path? | Particle Reference | The Particle asset to spawn when ejecting a shell, pass nil or an empty string for no particle Default nil |
See also GetParticlesShells.
Handlingfunctionsโ

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

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

GetRecoilOptimalโ
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.

GetRightHandOffsetOptimalโ
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.

GetSightFOVMultiplierOptimalโ
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.

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

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

SetHandlingModeOptimalโ
Sets how the Character grabs this Weapon
my_weapon:SetHandlingMode(handling_mode)
Parameters
| Name | Type | Description |
|---|---|---|
handling_mode | HandlingMode | The new how the Character grabs this Weapon |

SetLeftHandTransformOptimalโ
Sets where the Character's left hand holds this Weapon, relative to the Weapon
my_weapon:SetLeftHandTransform(left_hand_location, left_hand_rotation)

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

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

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

SetSightTransformOptimalโ
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)
๐ Eventsโ
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 |
Inherited events
ClassRegister, Destroy, Spawn, ValueChange
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)

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)

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)

Fireโ
Triggered when Weapon fires (this will be triggered for each shot)
Weapon.Subscribe("Fire", function(self, shooter)
-- Fire was called
end)

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


