Monday, 9 June 2014

Prototype - Pistol

Last and primary weapon will be simple pistol:
  • Small spread,
  • Only couple of bullets and after that -> reload,
  • Small damage,
At this point you should be able to create this weapon by yourself without my help but I will do some additional things here with Animation Blueprint. We will create custom recoil for this weapon, and move hands a little bit, as I can't animate things :) 

I have lot of experience using Anim Tree from Unreal Engine 3 but Animation Blueprints is just…wow. We can create almost everything, so let's start!

I will use Pistol from JonLundy3d. Import the model, create sockets, add new weapon type to WeaponType ENUM. 

Create a copy of Rifle_Projectile we created earlier. We will use the same settings here.

Muzzle Flash
Create copy of Rifle muzzle flash and disable looping. In Required Loops should be 1, and in Spawn you should use Spawn Burst. Experiment with parameters to have one muzzle flash on the screen without any loops. 

Create couple of variables in MyCharacter:
  • Pistol_CurrentAmmo (int),
  • Pistol Spread (float -0.05),
  • Pistol_IsReloading (bool),
  • Pistol_IsPistol (bool),
  • Pistol_ReloadTime (float 1.0),
  • Pistol_Recoil (float),
  • Pistol_MaxAmmo (int 6),
  • Pistol_IsRifle (bool),
In ChangeWeapon function (the place when you are assigning your Pistol mesh) you need to add Pistol_IsPistol to true and Pistol_IsRifle to false. 
Here's the main BP for Pistol:
PistolRecoil timeline is float with 3 points:
time 0 - value 0
time 0.07 value -4
time 0.2 value -0.03

As for the sounds just look at the Shooter Example sounds and pick yours. 

Animation Change / Custom Recoil / Reload
Open HeroFPP Animation Blueprint and add couple of variables:
  • Pistol_Translation (vector: -1, -26, -5)
  • Pistol_Rotation (rotator),
  • Pistol_HandTranslation (vector),
  • Pistol_HandRotation (rotator: -35,0,0),
  • Pistol_Recoil (float)
  • Pistol_IsReloading (bool),
Now assing those variables from MyCharacter in EventGraph like here:
Go to AnimGraph and try to create something like this:
I know how it looks but thanks to that we have Pistol hand animation. Normally you should have pistol hands animation. This is just changing bones translation and rotation to fit the pistol, it's easy but hard to read. 

Final Effect
At this point you should be able to create new weapons in UE4 without a problem!

In next post I will add first enemies and base for enemy spawning system!

No comments:

Post a Comment