Creating Assault Rifle

riflescreen1

BasicWeapon blueprint now supports a lot but it isn’t supporting automatic fire like assault rifles have. It will be really simple to implement now.

  • Rifle should use automatic fire,
  • We will use existing functionalities to drive this weapon,

Basically I will implement almost all of the weapons from Military Silver Pack and then move forward with gameplay. I want to have BasicWeapon functionalities fully implemented and tested out.

This Tutorial has been created using Unreal Engine 4.8.2. 
Make sure you are working on the same version of the engine.

For those who haven’t read earlier posts you should implement BasicWeapon blueprint to get this working. So check out earlier posts!

Stop Fire functionality

Add one new dispatcher to GameplayCharacter: OnWeaponStopFireWeapon (inputs WeaponType)

Now in BP_BaseWeapon

Add one new variable:

  • RiflesFireRate (float, default 0.1)

And one new function:

  • StopFire, – leave it blank,

Go back to GameplayCharacter and add new custom event: StopFire.

stopfireinput

So now we are driving input (only PC for now)

Creating Weapon

Go to BP_Weapon_AssaultRifle (we had created it earlier) and fill variables:

  • CurrentAmmoInMag: 30,
  • MaxAmmoInMag: 30,
  • CurrentAmmoInBackpack: 100,
  • MaxAmmoInBackpack: 100,
  • SpreadMin: 0.02,
  • SpreadMax: 0.2,
  • SpreadCurrent: 0.1,
  • SpreadDecreaseSpeed: 0.25,
  • MinWeaponDamageModifier: 0.7,
  • MaxWeaponDamageModifier: 1.2,
  • CritDamageModifier: 3,

Add one new variable:

  • IsRifleFiring (bool),

Now in event graph:

riflebp_graph

And that’s whole rifle functionality :) We are using timer to make automatic fire. It’s really easy.

Creating Animation

In HeroFPP_AnimationBlueprint. If you were reading earlier posts you should be able to do this by yourself. It’s the same thing:

  • Position hands to fit the weapon,
  • Use RifleRecoil bool to drive the recoil bone modify alpha,

So, create two new variables like in earlier post:

  • RifleRecoil (bool),
  • RifleRecoilAlpha (float)

Now in event Initialize Animation we need to know when we are firing and when firing ends.

animbpbeginplay

And in Update Animation let’s drive RifleRecoilAlpha

animbpriflerecoil

Anim graph should take RifleRecoilAlpha and modify bone.

riflerecoil

Final result:

One thought on “Creating Assault Rifle

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s