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.
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:
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.
And in Update Animation let’s drive RifleRecoilAlpha
Anim graph should take RifleRecoilAlpha and modify bone.
Final result:






Hello,
I maybe found a “bug” when you shoot more than your 30 bullet, it continue to fire.
You just need to add a branch like that : http://prntscr.com/80r2xh in the BP_Weapon_Rifle Event Graph
LikeLiked by 1 person