Gun Components
On the Gun Core’s game object, we can can add addition components that modify how the gun behaves. This gives us the ability to customize things like special effects, sounds, accuracy, etc.
There are 5 main components that can be modified or replaced.
Bullets
This defines how bullets act on impact including the decal we use to display bullet holes.
Properties
Is Enabled – Determines if the component can be used.
Is Active – Determines if the component is actively in use.
Inventory ID – Identifier of the bullet in the Basic Inventory item list. We use this to determine the quantity on hand when reloading.
Collision Layer – Layer that the bullet can impact.
Damage – Damage the bullet can inflict.
Impact Power – Physical force the bullet applies to rigid bodies on impact.
Impact Prefab – Prefab instantiated at the point of impact. This prefab typically has the decal and sound.
Handle
This is primarily used to modify the recoil (stability) and the spread (accuracy). In each case, we summarize the values for all the components and then use this sum as a multiplier to the Gun Core’s recoil and spread values.
Scope
The scope also modifies the stability and accuracy of the weapon. However, we also use it to modify the reticle that we show on the screen.
Properties
Manage Reticle – Determines if we enable the reticle when the gun is equipped.
Reticle BG Texture – Background texture for the reticle that this component sets.
Reticle Fill Texture – Foreground texture for the reticle that this component sets. This property isn’t really used yet.
Magazine
The magazine determines how many bullets the gun currently has equipped. When the Quantity goes to 0, the gun will need to be reloaded to be fired.
Properties
Capacity – Number of bullets the magazine is capable of holding.
Quantity – Number of bullets actually in the magazine.
Muzzle
The muzzle determines the sound of the gun fire as well as any effects that take place when a bullet is shot.
Properties
Fired Audio – Audio clip to play when the gun is fired.
Flash Prefab – Prefab to instantiate when the gun is fired. The instance of the prefab will be placed on the Gun Core’s Muzzle Transform.