Previous: MeleeWeapon, Up: Combat [Contents][Index]
Althoug originally developed for AK-47s and the like, this can be used for anything from a crossbow to a plasma rifle. It’s a multipurpose solution to get some decent FPS action going on. You will need to also set up a projectile prefab and some ammo handling using the included ’ClipInventory’ and related functionality. Clips are discarded on reload.
Pooling should only be used on mobile, to increase the stability of the game. It does this by delaying invocation of the garbage collector to clean up destroyed objects until the scene is unloaded.
bool showAmmoGUIShow how much ammo we currently have with a legacy Unity GUI? Not suitable for mobile devices.
Default value: true
Rect guiAreaNormalized viewport rectangle representing the area used by the legacy GUI, values between 0 and 1
Default value: new Rect(0.01f, 0.9f, 0.2f, 0.09f)
Texture2D crosshairsA nice crosshair texture
float crossSpreadScalarHow much to increase the size of the crosshairs when indicating spread
Default value: 1.0f
bool useFireButtonShould we use Unity’s built-in input for fire button handling? If false, send ’Fire’ each frame.
Default value: true
string fireButtonThe button in the Input Manager associated with shooting things.
Default value: "Fire1"
AimCorrectionTypes aimCorrectionWhat type of aim correction should we use? Raycast aims directly at what we point at, distant point aims at a point in the far distance representing our crosshair location (recommended for FPS games)
Default value: AimCorrectionTypes.None
GameObject projectileWhat do we spawn from the muzzle of the gun?
bool poolProjectilesShould the projectiles be added to a pool the first time they’re spawned so that they can be re-used from the pool later?
Default value: false
float inheritVelocityScaleMultiplied by the velocity before it’s transferred to the projectile
Default value: 1f
int magazineMaxHow many shots per mag?
Default value: 32
int magazineTypeWhich clip type from Clip Inventory do we use? First clip type is 0, second is 1, and so forth.
Default value: 0
float reloadTimeHow long does it take us to reload?
Default value: 2.2f
GameObject muzzleTransformA game object representing the exit point of the projectile
float refireTimeHow long, in seconds, between each bullet?
Default value: 0.4f
float muzzleSpreadMinMinimum variation of a bullet from center
Default value: .2f
float muzzleSpreadMaxMaximum variation of a bullet from center
Default value: 2.0f
float roundSpreadCostHow much the spread increases each time a projectile is discharged
Default value: .14f
float refocusRateHow fast the spread decreases
Default value: .16f
AudioClip fireSound’BANG!’
AudioClip reloadSoundSound made when reloading
AudioClip ammoExhaustedClickThe worst sound you can hear in a firefight
GameObject imageThe model of the weapon, if unassigned and no Animator found, no animations will be sent!
GameObject muzzleFlashAn object spawned at the muzzle transform representing visual flash effects
GameObject muzzleFlashSpawnTransformAn optionally different flash spawn transform
float flashDurationHow long should the flash object be alive?
Default value: 0.125f
string mecanimFireTriggerA Mecanim trigger that will be sent to the Image
string mecanimReloadTriggerA Mecanim trigger that will be sent to the Image
string mecanimAmmoExhaustedTriggerA Mecanim trigger that will be sent to the Image
MessageManager.ManagedMessage fireMessageMessage sent on successfully firing a round
MessageManager.ManagedMessage reloadingMessageMessage sent when starting to reload
MessageManager.ManagedMessage ammoExhaustedMessageMessage sent when we have run out of ammo
Causes the ranged weapon to emit a projectile, respecting all firing rules.
Initiates a reloading sequence for the weapon.
bool showAmmoGUIShow how much ammo we currently have with a legacy Unity GUI? Not suitable for mobile devices.
Default value: true
Rect guiAreaNormalized viewport rectangle representing the area used by the legacy GUI, values between 0 and 1
Default value: new Rect(0.01f, 0.9f, 0.2f, 0.09f)
Texture2D crosshairsA nice crosshair texture
float crossSpreadScalarHow much to increase the size of the crosshairs when indicating spread
Default value: 1.0f
bool useFireButtonShould we use Unity’s built-in input for fire button handling? If false, send ’Fire’ each frame.
Default value: true
string fireButtonThe button in the Input Manager associated with shooting things.
Default value: "Fire1"
AimCorrectionTypes aimCorrectionWhat type of aim correction should we use? Raycast aims directly at what we point at, distant point aims at a point in the far distance representing our crosshair location (recommended for FPS games)
Default value: AimCorrectionTypes.None
GameObject projectileWhat do we spawn from the muzzle of the gun?
bool poolProjectilesShould the projectiles be added to a pool the first time they’re spawned so that they can be re-used from the pool later?
Default value: false
float inheritVelocityScaleMultiplied by the velocity before it’s transferred to the projectile
Default value: 1f
int magazineMaxHow many shots per mag?
Default value: 32
int magazineTypeWhich clip type from Clip Inventory do we use? First clip type is 0, second is 1, and so forth.
Default value: 0
float reloadTimeHow long does it take us to reload?
Default value: 2.2f
GameObject muzzleTransformA game object representing the exit point of the projectile
float refireTimeHow long, in seconds, between each bullet?
Default value: 0.4f
float muzzleSpreadMinMinimum variation of a bullet from center
Default value: .2f
float muzzleSpreadMaxMaximum variation of a bullet from center
Default value: 2.0f
float roundSpreadCostHow much the spread increases each time a projectile is discharged
Default value: .14f
float refocusRateHow fast the spread decreases
Default value: .16f
AudioClip fireSound’BANG!’
AudioClip reloadSoundSound made when reloading
AudioClip ammoExhaustedClickThe worst sound you can hear in a firefight
GameObject imageThe model of the weapon, if unassigned and no Animator found, no animations will be sent!
GameObject muzzleFlashAn object spawned at the muzzle transform representing visual flash effects
GameObject muzzleFlashSpawnTransformAn optionally different flash spawn transform
float flashDurationHow long should the flash object be alive?
Default value: 0.125f
string mecanimFireTriggerA Mecanim trigger that will be sent to the Image
string mecanimReloadTriggerA Mecanim trigger that will be sent to the Image
string mecanimAmmoExhaustedTriggerA Mecanim trigger that will be sent to the Image
MessageManager.ManagedMessage fireMessageMessage sent on successfully firing a round
MessageManager.ManagedMessage reloadingMessageMessage sent when starting to reload
MessageManager.ManagedMessage ammoExhaustedMessageMessage sent when we have run out of ammo
Causes the ranged weapon to emit a projectile, respecting all firing rules.
Initiates a reloading sequence for the weapon.
Previous: MeleeWeapon, Up: Combat [Contents][Index]