Shooting System - NEW! {{ currentPage ? currentPage.title : "" }}

All the shooting logics from ACF are contained in to the ACFShootingComponent.

By default the shooting component is applied to both the ACFRangedWeapons and ACFCharacters.

In general you can add the shooting component to any entity and will grant ti the ability of “shooting things”.

  1. Adding the component to a new Entity

Please notice that this step is only needed if you are adding the component to a new Actor bowsince this steps are already

done for ACFRangedWeapon and ACFCharacter within ACF.

To make it work you’d need to call the SetupShootingComponent by passing as argument:

  • InOwner -> the pawn that has the Statistics Component, this will be used for the damage calculation

  • InMesh: The mesh used to shoot, the one which has the sockets for the muzzles and the shooting

Is also better to add a CollisionManagerComponent to the same entity since a couple of the shooting functions will require it to work properly.

2. Configuring the Shooting Component

The shooting comp can be customized to be used in a very wide range of situation.

First of all we’d need to tell the system where the shot should start in the provided InMesh (ProjectileStartSocket) and optional Sounds and Particles to be played as muzzles.

Secondly we’d need to define if our shooting will need to ConsumeAmmo. If you are using this to shoot magic projectile or something like this, you’d want to keep this false. In case of weapons, that bool is supposed to be true.

To make the shooting happen, then, in your AmmoSlots you’d need to have a valid Projectile for the shoot equipped.

The list of AllowedProjectiles will need to be filled with all the classes of projectile that can be used by this component.

When you equip a weapon with a shooting comp, ACF will try to automatically detect the best available ammos in inventory and equip it in the AmmoSlot automatically.

At every shot then the component will automatically remove the ammo from the ACFEquipmentComponent of the Owner provided in the Setup.

3. Magazine & Reload

Shooting Component also features a “Magazine” system. If this system is activated (UseMagazine set to true) when the weapon is equipped an ammount of projectiles (AmmoMagazine) will be moved from the Equipment to the Magazine of the weapon and at every shot this amount will be reduced. When the projectiles in the magazine will become zero, you’d need to call the Reload function within the ShootingComponent to refill the magazine.

Sample code for reloading:

3. Shooting Types

Now that we have properly setup our component, we can start shooting things!

The shooting component by default supports 2 ways of Shooting:

  • Shooting Projectiles: Will spawn a subclass of ACFProjectile that will have his ballistic movement based on the ProjectileMovementComponent, the damage will be done if the projectile hits an actor of the enemy team.

  • Swipe Trace: Will make a cylinder trace starting from the mesh socket of ShootRadius and that will hit for a length of ShootRange.

The functions to shoot within the component are:

  • ShootAtDirection: Will Shoot a projectile at the provided Direction, changing the Charge will affect the ProjectileSpeed (usefull for charged weapons). You can override default Projectile spawned by the component from ProjectileOverride.

  • ShootAtActor: Will Shoot a projectile towards the direction of the provided Target actor, with a randomic deviation that will not larger of RandomDeviation. changing the Charge will affect the ProjectileSpeed (usefull for charged weapons). You can override default Projectile spawned by the component from ProjectileOverride.

  • SwipeTraceShootADirection: Will shoot with a Swipe Trace to the provided Direction.

4. Shooting Actions

ACF already provides a couple of Actions that will provide to a Pawn the ability to shoot, in particular:

  • ACFShootAction: Default action to be used for a player controlled character to shoot with his currently equipped weapon, the shooting type will depend from the settings within the ACFRangedWeapon configuration. Open the ACFRangedWeapon blueprint to configure the Shooting Type and his shooting component

  • ACF_ChargedShootAction_BP: Used for charged shoot. Is a sustained action (an action with a looping animation) and the final charge of the shoot will depend on how long you keep pressed

  • ACFShootAction_FullAuto_BP: Is a sustained action for automatic weapons which continues shooting while you keep a button pressed. It’s associated animation will need to have a looping section (check the one provided in the sample).

  • ACFShootTargetActionBP: Used to automatically shot towards a specific actor, mostly used by AIs to automatically shot their current target in their ACF.

{{{ content }}}