Skip to content

Projectiles

Each Weapon can choose its projectile type by selecting it from the dropdown under the Projectiles section.

Shooter Weapon Projectile Selection

Raycast

The Raycast projectile option draws a line from the muzzle forward and hits the first collider object that intersects its path.

Shooter Weapon Projectile using Raycast

The Layer Mask allows to ignore certain colliders under the unselected mask(s).

The Max Distance determines the maximum distance at which the raycast line can reach.

The Pierces value is the number of extra objects it can pierce without stopping. By default it is zero, but you can make a weapon pierce through colliders by increasing the value.

If the Use Line Renderer field is set, a list of options will appear below, which allow to configure the material, color, width and texture mode of the trail left by the projectile.

Simulate bullet speed using Line Renderers

Although using the Raycast mode makes the projectile have an infinite amount of speed you can simulate the projectile's travel time by making adding a Line Renderer who's trail quickly decreases towards the point of impact.

This will give the player the illusion that the projectile travels very fast, but it's not instantaneous.

Kinematic Projectile

The Kinematic Projectile option instantiates a game object at the muzzle and shoots it forward using its settings.

Shooter Weapon Projectile using Kinematic instance

Collision with Kinematic

Do not add a Collider or Rigidbody to the kinematic projectile. Collisions are handled internally using raycasts between frames to avoid very fast projectiles from ghosting through thin geometry.

This means that Kinematic projectiles do not have a volume and are infinitely small. If you want to make projectiles use their shape to collide with other objects use the Rigidbody Projectile.

The Prefab field is mandatory and is used to instantiate the projectile at the tip of the muzzle.

The Delay field will defer the movement of the projectile the specified amount of seconds. If the value is greater than zero, the projectile will follow the muzzle tip until the timeout has finished and it's ready to be sent forward.

The Force value indicates the simulated force the bullet will be shot with. The higher the value, the faster it will travel.

The Gravity field allows the projectile to be affected by a downward force.

The Air Resistance field allows bullets to lose speed over time. This field can be a combination of both bullet drag, temperature, air pressure and resistance.

The Wind Influence field is a coefficient that indicates how much does wind affect the bullet's trajectory. A value of 1 means the wind will completely affect the bullet while a value of zero will skip the wind calculations.

Sniper Simulator

Some types of ammunition are affected more or less by wind, depending on its material, shape and spinning factor. You can model this behavior by letting the Wind coefficient be tied together to the ammunition used.

The Attraction Force can be used to nudge the projectile towards a specific target. This target must be set in the Attraction Target value.

The Layer Mask field allows the projectile to ignore certain colliders defined in the mask and the Max Distance determines how far the projectile can travel.

The Hit field is a dropdown which can be:

  • On Impact: The projectile reports a hit as soon as it collides with an object.
  • On Timeout: The projectile reports a hit after a certain time has passed.

The Pierces field allows the projectile to pierce through a number of colliders before being destroyed.

The Timeout field allows the projectile to be automatically destroyed, even if it hasn't collided with any object and still has travel distance available.

Rigidbody Projectile

The Rigidbody Projectile option allows to instantiate an object that uses Unity's physics engine to drive its translation and rotation.

Shooter Weapon Projectile using Rigidbody instance

Rigidbody vs Kinematic

The Rigidbody is similar to the Kinematic system, but it uses Unity's physics engine which is multi-threaded, improving performance, but also has fewer options.

The Prefab field is mandatory and is used to instantiate the projectile at the tip of the muzzle.

The Delay field will defer the movement of the projectile the specified amount of seconds. If the value is greater than zero, the projectile will follow the muzzle tip until the timeout has finished and it's ready to be sent forward.

The Impulse and Impulse Force determines the force applied to the rigidbody and whether the force takes into account the projectile's mass or not.

The Mass field, as its name implies, defines the mass of the projectile.

The Air Resistance field allows bullets to lose speed over time. This field can be a combination of both bullet drag, temperature, air pressure and resistance.

The Wind Influence field is a coefficient that indicates how much does wind affect the bullet's trajectory. A value of 1 means the wind will completely affect the bullet while a value of zero will skip the wind calculations.

The Attraction Force can be used to nudge the projectile towards a specific target. This target must be set in the Attraction Target value, and the force applied towards its position may or may not take into account the mass of the projectile.

The Max Distance determines how far the projectile can travel before being automatically disposed.

The Hit field is a dropdown which can be:

  • On Impact: The projectile reports a hit as soon as it collides with an object.
  • On Timeout: The projectile reports a hit after a certain time has passed.

The Timeout field allows the projectile to be automatically destroyed, even if it hasn't collided with any object and still has travel distance available.

Tracer Target

The Tracer Projectile option allows to define a target to shoot at, and the projectile will always move towards it, regardless of its shooting direction.

Shooter Weapon Projectile using Tracer mode

When to use Tracer

The Tracer Target is usually used when you have a lock-on on a target and you want shots to (almost) always impact the target. For example, a barrage of missiles or a weapon that automatically shoots at the nearest enemy.

The Prefab field is mandatory and instantiates the projectile at the tip of the muzzle.

The Delay field will defer the movement of the projectile the specified amount of seconds. If the value is greater than zero, the projectile will follow the muzzle tip until the timeout has finished and it's ready to be sent forward.

The Speed field determines how fast the projectile moves.

The Target value is mandatory and is required in order to translate the projectile from the muzzle to the targeted game object's position.

The Deviation X and Deviation Y fields allow to artistically deviate the path of the projectile while making sure it always lands on the target.

Using Bézier curves

The Tracer Target uses a Bézier curve in order to draw the projectile's path. The Deviation fields act as control points on the start of the curve, in local space from the muzzle's direction.

The Layer Mask field allows the projectile to ignore certain colliders defined in the mask.