Last updated
Last updated
The Weapon component is the main component in FP Motion related to weapons, its primary purpose is to make an object into a gun by allowing it to shoot, have ammo, and other things.
This component also holds the information on what camera and weapon state file the object it's placed on uses allowing for much customization.
Guns in the asset all have this component attached to them.
In FP Motion, a weapon has two main things that it can do, those being shooting and reloading; thus, the Weapon component allows weapons to do just that, and in doing so, it makes use of the event system that the asset has in place.
For that purpose, the component subscribes its functions to the shoot, and the reload events.
Whenever the shooting event gets invoked, it makes sure that the weapon can shoot by making a fire rate calculation (time since last shot).
The way to use this component is by placing it on the weapons that the player can wield; this only works if the component and other FP Motion scripts are in place.
FP Motion also has a separate Projectile Spawner script that enables the guns in the asset to shoot 'projectiles.'
Another thing to keep in mind is that we usually add weapons as children of a Holster object to allow the player to switch between them, but some games might not require this feature.
When changing how a gun in FP Motion functions, it is essential to look at simple fields like fireRate
or ammo,
but it is also crucial to look at the States fields.
These two fields, cameraStates
and weaponStates,
hold the States files that change how the gun and the camera behave in the different states.
Other important things include the fire rate and ammo per magazine fields.