⚙️
FPS Framework
Asset StoreFab
  • Get Started
    • Welcome!
    • Setup
  • Tutorials
    • Character
      • First-Person Controller
      • Inventory
      • Firearm
        • Basics
        • Advanced
        • Other
          • Spray pattern
          • Attachment System
          • Projectile System
      • Explosive
    • Systems
      • Audio System
      • Animation System
      • Interactions
        • Pickable
      • Save System
      • Settings System
    • Tools
      • Extension Methods
    • UI
      • FPS Counter
      • Get Name
      • Image Size Fitter
  • Other
    • Full Change Log
      • 2025 Change Log
      • 2024 Change Log
      • 2023 Change Log
      • 2022 Change Log
Powered by GitBook
On this page
  • Creating a new projectile
  • Fields
  • Ignoring hits
  • Hit events
  • Transferring into explosive projectile

Was this helpful?

  1. Tutorials
  2. Character
  3. Firearm
  4. Other

Projectile System

A detailed guide on how to use the projectile system.

PreviousAttachment SystemNextExplosive

Last updated 1 year ago

Was this helpful?

While Projectiles (Physical Bullets) can be used, FPS Framework uses Hitscan (Raycast) by default, which are the most common performant method in all first-person shooter games. If you would like to use hitscan you can check this out.

Creating a new projectile

To create a new projectile first create an empty game object and add the component "Projectile" to it. Your game object's inspector should look like this:

This is the default values (Could be different depencing on the current version of FPS Framrwork that you are using.

Fields

Name
Description

Hittable layers

The layers which this projectile can detect

Decal direction

The direction of the decal according to the normal value of the raycast

Penetration strength

This amount, which may be referred to as the projectile's "health," is set by the "Default Decal" component and decreases each time the projectile hits an item. The default health damage value is 10 in the event that this component is unavailable.

Speed

The speed of the projectile

Gravity

The gravity multiplier to this projectile. A value of 2 is equal to Physics.gravity * 2

Force

The force the projectile can apply when it hits an object.

Lifetime

The time after which the projectile automatically destroys itself.

Default decal

The default hit impact effect if there's no "Custom Decal" component on the object that got hit.

Destroy on impact

If on the projectile will automatically destroy itself on the first hit.

Use source velocity

If on the projectile will add the force of the shooter to its initial velocity.

Use auto scaling

If on the projectile will scale itself to always look the same to the shooter.

Scale multiplier

The scale of the projectile which the projectile needs to maintain, this is not affected by "Use auto scaling" toggle.

Range

The range of the projectile in which it can deal damage.

Damage range curve

How the damage is affected by its travel distance.

Ignoring hits

To ignore hits from all projectiles to a certian game object, you can do these

  • Assgin a layer to that game object and remove it from the hittable layers

  • Add the component "IgnoreHitDetection" to the game object you want to ignore hits.

This is how your game object's inspector that ignores hits look like:

Hit events

The projectile can send messages to your custom scripts via a callback function like unity's callbacks e.g OnTriggerEnter(). To add these functions to your script you need to implement the interface "IOnHit" or any of its variants to your script like this:

using Akila.FPSFramework;

public class Test : MonoBehaviour, IOnHit
{
    public void OnHit(HitInfo hitInfo)
    {
        throw new System.NotImplementedException();
    }
}

The function "OnHit()" will be called when the projectile hit any object with this component along with a collider. You can test it by printing a message to the console. The function has a argument of "HitInfo" which contains useful information about your hit.

The hit functions are called from the interface "IOnAnyHit" as well as "IOnHit" and their variants.

Transferring into explosive projectile

You only need to add the "Explosive" component to the same game object that already has the projectile on it in order to change this projectile from being a simple "Bullet" to an explosive one. The rest is explanined in

Explosive
Default projectile's inspector
Ignore hit detection's inspector