Ammunition (from now on Ammo) are the other objects used by the Shooter module that allow you to create any kind of weapon. Weapon objects allow you to define how the Character behaves using a certain gun, but Ammo allows to define what happens when shooting it, charging shots, how the aiming is done, etc...
The Ammo object is split in 3 big blocks: naming, a few expandable sections and the three Action lists at the end.
This block is very similar to the Weapon object. Allows you to give the ammunition a name and a description. These values can be localized.
It is important to notice there's another field called Ammo ID. This field allows to identify the ammunition among the rest. It is important to use a unique value. By default we provide a very long text composed of lower, upper and numeric characters. However, you're feel free to change this for a more meaningful name.
The Ammo object is organized in 7 different expandable sections. Each one deals with a particular feature, such as playing an animation when the weapon is shot, how the weapon travels to its destination, etc...
The General section manages common settings related to how the weapon behaves.
The Fire Rate property tells the maximum amount of bullets that the weapon can fire per second. It is important to note that successive bullets fired out of the rate period will be ignored.
Infinite Ammo checkbox tells the Shooter system to skip checking and subtracting bullets from the magazine. However, notice that, because bullets won't decrease, your clip size will never be reduced and the shooter won't ever need to reload.
Clip Size is the amount of bullets that are available to be shot before reloading the gun.
Auto Reload allows to immediately reload the weapon when trying to shoot and there are no bullets left in the clip. This is the default behavior in most games.
Reload Duration defines how long will it take for a weapon to be reloaded. It is important to mention that this time is also used to stretch or shrink the animation played while reloading.
The Aiming section deals with how the Weapon with this particular Ammo aims at its target.
The aiming section has an aiming mode dropdown with three options: None, Crosshair and Trajectory. Let's break them down.
There's no visual indication to how the bullets will be fired. Not commonly used, but if your weapon has a crosshair integrated in your 3D model, it could be useful.
Crosshairs are the little cross that appear at the center of most first person shooter games. It gives information about where the bullets will impact as well as the current accuracy.
The Crosshair Mode displays a couple of properties. Crosshair property allows to define the prefab object that will be used when aiming.
Focus Time defines how long will it take for the weapon to go from least accurate to maximum accurate. For example, a value of 0.25 means it will take 0.25 seconds to steady the hand. We'll talk more in depth about accuracy at the Shooting section.
The Trajectory aiming mode is the most complex one. It allows to visually display a diegetic line or a gravity-affected trajectory gizmo.
The first property Mode allows to change between a Curved or a Straight line renderer. In either case, you can define an Offset in local space from where the line renderer will start.
Min Velocity and Max Velocity depend on the charge amount.
The Min Velocity and Max Velocity tell the minimum velocity at which the projectiles will be shot at each edge of the charged shot. In between values will be interpolated.
To know more about charged shots, see the Charging section.
The Resolution property defines how smooth the curved line renderer will be displayed. The curved gizmo is painted using Line Renderers, and the Resolution property defines the length of each segment in the Line Renderer.
The rest of the properties define how the Line Renderer will be displayed, including its Width, the Material used as well as where the faces of the Line Renderer will face.
Firing projectiles can be done via two different modes: Normal shots and Charged shots. This section deals with the later one.
Charge Type is a property that affects both shooting modes; charged and normal shots. This property defines how this ammunition is shot.
Disable Charge: This ammunition can not shoot charged shots. It grays out the rest of the Charging section properties.
Require Charge: The ammo can only shoot charged shots. It will ignore any attempt to shoot normal shots.
Optional Charge: The ammo can both shoot charged shots and normal shots.
Min Charge Time is the minimum amount of time needed for a charged shot to be considered as such.
Charge Time property is the amount of time required to go from a charge of 0% to a 100% charged shot. This value can come from a Global Variable, so it can be dynamically set at runtime (for example, upgrading the weapon can yield in decreased duration).
Charge Value is an optional property that can be used to store the current charge of the weapon to be used at runtime. This is useful if you want, for example, to display a particle effect when the weapon is fully charged. This can be done by querying the current amount of charge stored in a particular variable.
The Shooting section defines how bullets are fired. There are different shooting modes, each of them with its own particular set of properties: Projectile, Raycast, Raycast All, Trajectory Cast, SphereCast and SphereCastAll.
Shooting Projectile Type is the easiest to set up. It instantiates a prefab, defined by Prefab Projectile, where the muzzle is and moves it forward.
If the projectile contains a Rigidbody component and the Aiming Mode is set to Trajectory, it will also apply force based on the Min Velocity and Max Velocity properties found at the Charging section.
Prefab Muzzle Flash instantiates a prefab at the muzzle position. This is typically used to play a particle effect.
Bear in mind that the trajectory computed by the aiming mode doesn't necessarily coincide 100% with where the projectile will land. See the GIF above how the arrow gets stuck just a few millimeters below where the trajectory indicated. This is due to the arrow being computed by a different system (Unity Physics engine) than the trajectory gizmo.
Shooting Raycast and Raycast All modes (also know in other engines as hit-scan weapons) immediately hit the target as soon as the weapon is fired. This is done checking for any collisions between the muzzle and the direction of the muzzle.
Distance and Prefab Muzzle Flash properties define the maximum distance the collision check will reach. As soon as the scan starts, a prefab (if any) will get instantiated where the muzzle is.
If any object is returned by the collision check (or all of them if the Shoot Type is set to Raycast All), an instance of the Prefab Impact Effect will be instantiated.
Layer Mask allows to ignore objects that are part of the ignored layers. Very useful if you plan on making projectiles penetrate thin surfaces, such as paper walls or water.
If Push Force is greater than zero, each object returned by the hit-scan will be examined. If a Rigidbody is found, it will apply an impulse force at the contact point equal to this property's value.
Shooting Trail allows to draw a trail that simulates the trail left by the bullet.
This effect is achieved by drawing a trail from the muzzle to the object hit, and making the tail of the trail travel towards its head.
You can customize the Width of the trail, the Duration, which defines how long will it take for the tail to reach the head, as well as change its Material. Alignment defines where the plane of the trail will be oriented towards and Texture Mode how the material will be laid out along the trail.
This Shooting Type is similar to Raycast, but instead of using two endpoints from where to scan for collisions, it uses a curved trajectory.
All properties in Trajectory Cast are exactly the same as Raycast and Raycast All modes.
These shooting modes are homologous to Raycast and Raycast All, with the difference that they allow to add volume to the ray shot. This volume is defined by a radius. This is specially useful for weapons that shoot spread shots, such as a shotgun or a flamethrower.
In order to better visualize how SphereCast works, imagine that, at the tip of the gun, there's a sphere with a certain radius, and everything that collides with this sphere being swiped forward will be considered shot by the bullet.
Recoil defines how much accuracy will be lost after shooting with this ammunition and it is percentage based.
Delay is a property that allows to add a certain amount of delay (in seconds) between the animation, sound and particle effects are played and the actual shot is taken. This value is generally low, between 0 and 0.5 seconds. This allows, for example, to swing a wand before casting a Fireball spell.
Min Spread and Max Spread define how much accurate the guns are. If the shooter is standing still and the accuracy reticule is at its minimum, it means that the next shot fired will have an accuracy of Min Spread. On the other hand, if the shooter is running, the crosshair reticule will be at its widest and the precision of the shot will be Max Spread. In between values will be calculated by interpolating Min Spread and Max Spread.
When shooting with a weapon, the deviation of the shot based on the accuracy is not calculated as a linearly distributed random value, but with a Gauss-Laplace Random Distribution.
This results in more realistic shots, where most shots are localized at the center and fewer on the sides.
Some weapons show the amount of ammunition. For example, guns don't really need to show the amount of bullets in the clip, but Bows, on the other hand, need to display an arrow being held by the shooter. This is where this section comes into play.
Whenever a weapon is equipped it checks if there's at least one projectile in the clip. If there is, an instance of the Prefab Ammo will be created as a child of the Bone, with an offset specified by the Position and Rotation fields.
After shooting, if the clip becomes depleted, it will automatically destroy the instance of the ammo object.
As its name implies, the Audio section lets you specify different audio clips for different situations.
Audio Shoot: An audio clip played when the weapon is fired.
Audio Empty: An audio clip played when the weapon is fired but there are no bullets in the magazine.
Audio Reload: An audio clip played when the weapon is reloaded.
The Animations section allows to configure what Character animations will be played in different situations.
Animation Shoot is an animation clip played whenever the Character shoots. It also has an optional Avatar Mask that allows to define which body parts will be affected by the animation.
Similarly, the Animation Reload also is a field that accepts an Animation Clip as well as an Avatar Mask.
The Ammo object contains three tabs with different Actions executed depending on the shooting event being executed.
An Actions list executed whenever the weapon with this Ammo starts charging.
An Actions list that is executed whenever a shot is fired. Notice that doesn't distinguish between charged or normal shots. It is always executed.
An Actions list that is executed after a successful charge is released. This Action is executed after the On Shoot Actions.