This will be the last weapon from Military Silver Pack implemented. Basically BaseWeapon is finished now and adding new weapons is really easy.
What’s new in this post is camera shakes which can be used on explosions or big weapon fire effect.
1 2 |
<strong>This Tutorial has been created using Unreal Engine 4.8.2</strong>. Make sure you are working on the same version of the engine. |
WeaponType
Open WeaponType enum and add RocketLauncher there. WeaponType is used on AnimationBlueprint so if you are adding weapon which will have different hands animation you need to add new type here.
New Socket
Open hands skel mesh (Hero_FPP) and add new socket named S_RocketLauncher to b_RightWeapont bone.
Updating Animation Blueprint
Now we need to update HeroFPP_AnimationBlueprint so hands will hold rocker launcher. Add new variables:
- RocketLauncherRecoil (bool),
- RockerLauncherRecoilAlpha (float),
Basically if you implemented rest of the weapons you know exactly what do to now.
In event graph Initialize Animation add RocketLauncherRecoil on FireWeapon.
And in UpdateAnimation drive RocketLauncherRecoilAlpha.
Interpt Speed is different here than in other weapons.
Now in Anim Graph make sure you connect pose to RocketLauncher enum! Here’s my graph:
BP_Weapon_RocketLauncher
Now create new blueprint extending from BP_BaseWeapon name it BP_Weapon_RocketLauncher.
We need to modify some variables:
- CurrentAmmoInMag: 1,
- MaxAmmoInMag: 1,
- ReloadTime: 3,
- AttachSocketName_FPP: S_RocketLauncher,
- WeaponType: RocketLauncher,
- SpreadMin: 0.1,
- SpreadMax: 0.4,
- SpreadCurrent: 0.2,
- FireType: Projectile,
Set WeaponMesh component to Rocket_Launcher_A.
Adding weapon to backpack
Now open ShooterGameInstance and add this weapon to Inventory_Backpack so you can choose it and equip.
Impact Effect
Create new blueprint extending from ImpactEffect and name it Impact_RocketLauncher.
- DefaultFX: P_RocketLauncher_Explosion_01
- DefaultSound: RocketLauncher_Explosion_Cue
- Is Using Hit Result: False,
Projectile
Create new blueprint extending form BP_BaseProjectile named BP_Projectile_RocketLauncher.
Components:
- Mesh should be set to RocketLauncherA_Ammo,
- Add new Particle System Component: P_RocketLauncher_Trail_01,
ProjectileMovement:
- Initial Speed: 5000,
- Max Speed: 5000,
Variables:
- IsCausingRadiusDamage: true,
- ImpactEffect: Impact_RocketLauncher,
Camera Shake
Create new blueprint extending from CameraShake. Name it CameraShake_RocketLauncherFire.
Updating weapon blueprint.
Open BP_Weapon_RocketLauncher and update these variables:
- ProjectileClass: BP_Projectile_RocketLauncher,
- ImpactEffect: Impact_RocketLauncher,
Now in event graph create Event Fire.
Now you can create new AmmoData in ShooterGameInstance for rocket or just fill AmmoData in weapon blueprint.
And that’s it! Final result: