Advanced
The full details for everything related to the firearm and how to use it.
Last updated
Was this helpful?
The full details for everything related to the firearm and how to use it.
Last updated
Was this helpful?
After clicking "Create" as described on the page, a new FirearmPreset file will appear, along with a gun prefab if the "Generate Prefab" option was enabled.
As seen in the screenshot, there's a genrated prefab and firearm preset scriptable object ad a firearm game object all with the same name as the given name in the firearm wizard.
To edit the firearm, open the generated prefab and replace the default cube by dragging and dropping your custom mesh into the same location.
Now that the firearm is correctly positioned, delete the "Cube" object highlighted in the screenshot above.
The screenshot below illustrates that the aiming animation is slightly off-center.
For example, how do you adjust the aim animation? The answer lies within the aim animation itself, which you can find under AR-15 (or your firearm's name) > Transforms > Clips, then locate the Aim Animation GameObject.
This is the Inspector of the Aim Animation GameObject.
As shown above, you’ll find the "Position" and "Rotation" fields—adjust the Position values to correct the offset. After these adjustments, you can see that the aiming animation is now in center.
There are two types of animations: keyframe animations (created in software like Blender) and procedural animations.
You should already have essential animations, such as Reload and Idle. These are the core animations you need, but if you require additional ones, you can always add them later.
To begin adding animations, first attach the Animator component to the animated model you've added, like this:
The animations will function properly if the Animator Controller is correctly set up in the Controller field. You can do one of the following:
Duplicte one of the default controller and use it
Create it from scratch
In the first scenario, simply duplicate the Animator Controller of the default firearm type you want to create. The default animation controllers can be found at FPS Framework > Assets > FPS Framework > Art > Animations > Animator Controllers > Controllers
The Animator Controller for the default firearm contains several parameters that you can use to transition to and from the reload animation, or any other animation you need.
If you created an Animator Controller from scratch, make sure to add the parameters shown in the screenshot above.
You can use them in your animation transitions to configure your animations. To create a reload animation using this method, for example, add a transition between your dile animations and reload animation with the condition of transitioning if IsReloading is true and transitioning back if IsReloading is false. You can also include Ammo in the equation with an empty reload animation and a normal reload animation.
If your firearm doesn't shoot while a specific keyframed animation (such as those in bolt-action firearms) is playing, add the animation state name to the "Restricted Animations" list in the firearm preset to prevent shooting during that animation.
Effects like muzzle flashes and other particle system-based effects can simply be dragged and dropped into the firearm game object (As children), and they will function correctly without the need for additional setup.
Other effects, such as the HUD, pickable versions of the firearm, and more, are all found in the firearm preset. Below are all the available options.
The casing, for example, is a prefab that needs to be assigned to the "Casing" field in the firearm preset under "Fire".
Firearm HUD elements, such as ammo counters and reload warnings, are all part of the weapon HUD. To enable them, assign a Firearm HUD prefab (e.g., the preconfigured FirearmHUD prefab) to the "Canvas" field in the firearm preset.
If you're using Hitscan shooting, you'll see a field called "Default Decal" in the firearm preset. This field represents the default hit impact effect—if the object hit doesn't have a custom decal component, this prefab will be used instead. There's also an associated field called Decal Direction, which defines the orientation of the decal based on the hit.normal
value.
The assigned Ammo Profile in the firearm preset defines the type of ammo used by the firearm. To create a new ammo type, right-click in the Project window and select Akila > FPS Framework > Weapons > Ammo Profile. You can then name your ammo type and assign it to the firearm preset.
As of now, if you enter play mode you should see this, even when the ammo type is assgined to the firearm preset.
This happens because the firearm is attempting to locate the assigned ammo type from its Firearm Preset in the inventory. If it's not found, it is marked as "Unknown Ammo Profile". As a fallback, the system generates a local ammo profile and uses that instead.
Make sure to assign the ammo type you created to the inventory's Collectables list.
Now the firearm should identify the new ammo type.
You can find the "ReloadMethod" under "Fire" in the firearm preset. It defines how the firearm reloads its ammunition.
If the reload method is set to "Default", pressing the reload button will make the firearm wait for the duration specified in the "Reload Time" field. Once the time is up, the firearm will refill its magazine to full capacity.
If the reload method is set to "Scripted", it uses a different approach that doesn't work as directly as the "Default" method.
The "Scripted" reload method requires Unity animations with animation events. Here’s how it works:
First, create an animation state in your Animator Controller (e.g., "Reload").
Set the "Reload Animation State Name" in the firearm preset to the exact same name as your reload animation state.
When you press the reload button, the firearm will begin playing the reload animation.
From this point, the responsibility of adding ammo lies with the animation itself, using animation events to trigger the ammo addition during the reload process.
To allow the animation to add ammo, select your reload animation in the project window, and add an animation event as shown below. This event will trigger the ammo addition at the appropriate point in the animation.
As shown above, a new animation event is added at the point where the player should be inserting the magazine/bullets. This animation event calls the "Reload" function, and the "Int" value is set to 1, meaning one bullet will be added.
For this to work, make sure to attach the "WeaponEvents" script to the same GameObject that has the Animator playing this animation (i.e., the animated mesh with the Animator component).
If you press play, you’ll notice the animations are functional. However, they might not perfectly suit your needs—such as the aim animation being slightly off-center or the sprint animation not aligning correctly. Fortunately, these issues are easy to fix thanks to the . (Refer to the Animation System page for more details.)
Keyframe animations rely on Unity's animation system, which is explained in ; you should watch it if you don't know how to utilize Unity's animation system.
The page explains how procedural animations work. Be sure to read it for detailed instructions on how to add new animations.
To add crosshair to your firearm you migh want to take a look at first. You need to assgin a crosshair into the field corsshair in the firearm preset.
The Replacement is the pickable version of the firearm. For more details, refer to the pages. To set it up, assign the pickable version of your firearm to the "Replacement" field in the firearm preset.