Saturday, 31 May 2014

Prototype - First Weapon Polishing

So we wan't to create an feeling of shooting the weapon. For now it's just not fun to shoot. 

What can we improve to have better quality:
  • MuzzleFlash effect, 
  • More visible trail,
  • Impact effect,
  • Add effects to weapon itself,
  • Recoil,
  • Lighting effects (will be hard to do in mobile but we will try)
You should view this amazing tutorial about creating projectiles.

Muzzle Flash Effect.
I will use content from Strategy Game here so you need to copy content from it to your project. When you copy the content create duplicate of this particle: ParticleSystem'/Game/Environment/Effects/particles/Arbalest_Projectile.Arbalest_Projectile'

1. Open duplicated particle,
2. Disable "glow" and "particle emitter" emitters:

3. Select Required for "Tail" emitter and change values like in screenshot:

4. Select Spawn and change:
Rate -> Distribution -> Constant to 55
Rate Scale -> Constant -> 1
Burst List -> Count 0

Burst List -> Count Low -1
Burst List -> Time 0
Burst Scale -> Constant 1
5. Select Initial Size and change:
Start Size -> Max X: 10, Y: 25, Z:10
Start Size > Min X:7, Y:25, Z:4.5
6. Select Lifetime and change:
Distribution -> Min 0.05

Distribution -> Max 0.05
Can Be Baked -> false
7. Select Initial Velocity and change:
Start Velocity -> Distribution -> Max X:-500, Y:0, Z:0
Start Velocity -> Distribution -> Min X:-300, Y:0, Z:0
Start Velocity Radial -> Min: 0, Max 0,
8. Select Initial Location and change:
Distribution -> Max X:2, Y:0, Z:0 - the same for Min
9. Select Initial Rotation and change Distribution Min to 0 and Max to 1.
10. Select Size By Life and copy variables from the screenshot:

11. Leave Initial Color unchanged,
12. Leave Scale Color / Life unchanged,
13. Select Size Scale and Change it to X:2, Y:2, Z:2,

Now we need to add new Emitter in Cascade.
14. Right click on free space near last Emitter and create New Particle Sprite Emitter:
15. Chose Required,
16. For material use Material'/Game/Effects/Materials/LensFlare/M_LensFlare_02.M_LensFlare_02'
17. Screen Alignment should be PSA_Rectangle,
18. Use Local Space should be True,
19. Use Legacy Emitter Time should be False,
20. Emitter Loops should be 1,
21. Chose Spawn,
22. Rate -> Constant should be 0,
23. Rate Scale -> Constant should be 1,
24. Burst List -> Count set to 1, Count Low set to 1 and Time to 0,
25. Burst Scale -> Constant should be 0,
26. Select Lifetime and change Lifetime -> Min 0 and Max 0.1,
27. Select Initial Size,
28. Start Size -> Max -> X:100, Y:40, Z:0,
29. Start Size -> Min -> X:80, Y:30, Z:0,
30. Select Initial Velocity,
31. Start Velocity -> Distribution Min and Max XYZ should be 0,
32. Start Velocity Radial Min and Max should be 0 as well,
33. Select Color Over Life and copy variables from screenshot:
34. Right click bottom of your parameters and create Size Scale parameter:
35. Select it and use Constant X:1, Y:1, Z:1,
36. Again right click and create new parameter: Size By Life. Copy variables from screenshot:
That's all for this particle system I won't be trying to learn you Cascade because it's really advanced tool and I'm far from FX Artist, but you should try experiment with different settings to check how it's working. There is a lot of Cascade tutorials on Youtube as well. Take your time!

Before assigning this particle I will add something to the weapon.

Add effects to weapon itself
Create a copy of the same material that we have copied earlier: ParticleSystem'/Game/Environment/Effects/particles/Arbalest_Projectile.Arbalest_Projectile'

1. Open it,
2. Disable "glow" and "Particle Emitter" emitters,
3. Close Cascade and open your MyCharacter blueprint,
4. Open ChangeWeapon function that we have created earlier and in the end of your blueprint add Spawn Emitter Attached and assing copied particle that we have created like in the screenshot:
5. Go to your main blueprint (Event Graph),
6. Find the spot where you are firing and Playing Sound at Location,
7. Add new block Spawn Emitter at Location and chose the particle that we have created earlier (not the one above - the first one;))
Compile your scripts and you should have the same effect as mine. It's not perfect but for prototype it will work,

More visible trail
This will be from Shooter Example you should already have content from this project if you were reading older posts.

1. Copy this particle: ParticleSystem'/Game/Effects/ParticleSystems/Weapons/AssaultRifle/Muzzle/P_AssaultRifle_Trail.P_AssaultRifle_Trail'

2. And just change initial size of both emitters to X:15, Y:15, Z:15. That's all here. Close Cascade,

3. Open your projectile MyProjectile blueprint,
4. Create Particle System Component and assign particle that we have created. Name it Trail,
5. Go to Graph,
6. Use Post Begin Play and Set Vector Parameter of the Trail,
You should have trail now when shooting.
Impact Effect
Find P_Launcher_MF particle and create a copy, open it,

1. Disable "Tail" emitter,
2. Select Size Scale of "Spikey" emitter,
3. Change Size Scale -> Distribution -> Constant to X:1.5, Y:1.5, Z:0
4. Create new Particle Emitter,
5. In Required use Material'/Game/ExampleContent/Effects/Materials/m_flare_01.m_flare_01'
6. Screen Alignment should be PSA Velocity,
7. Disable Use Legacy Emitter Time,
8. Emitter Loops should be 1,
9. Select Spawn,
10. Rate Distribution Constant set to 20 and Rate Scale set to -1,
11. Burst List Count: 30, Count Low: 15, Time: 0,
12. Burst Scale Constant 1,
13. Select Lifetime,
14. Lifetime -> Min 0.5 and Max 1.0,
15. Select Initial Size and change it to X:5, Y: 15, Z:5,
16. Add new Sphere parameter (it will be in Location),
17. Start Radius -> Constant set to 5,
18. Velocity should be set to true,
19. Velocity Scale -> Constant set to 300,
20. Start Location -> Constant X:0, Y:0, Z:0,
21. Add new Acceleration parameter,
22. Distribution set to X:0, Y:0, Z: -2000,
23. Always in World Space should be true,
24. Add new Size By Life parameter,
25. Copy variables from screenshot,
26. Close cascade - this will be your impact particle,
27. Open projectile MyProjectile blueprint,
28. Open Graph,
29. Navigate to Event Hit,
30. Add Spawn Emitter at Loaction block and use created particle as template.
This will spawn your impact particle. Try to change variables in Cascade to get better results.

Last thing we will add to impact effect will be sound. Copy content from Content Examples and find those sounds:
Cleaver_ImpactLayerSpark01, Cleaver_ImpactLayerSpark02, Cleaver_ImpactLayerSpark03
And sounds from Shooter Example:
AssaultRifle_Shot02, AssaultRifle_Shot02_Stereo, AssaultRifle_Shot03
Copy those sounds to new folder. 

1. Create new Sound Cue,
2. Open it,
3. Try to do the same as here,
Attenuation settings:
4. Close SoundCue editor,
5. Open projectile MyProjectile and go to Graph,
6. After Spawning Impact Particle create new block Play Sound at Location and chose your sound cue you have created:
Now you should get impact effect and sound!

As for now I will leave current animation unchanged. It isn't looking bad, should be enough for prototype.

Lighting effects (will be hard to do in mobile but we will try)
I weren't able to do this unfortunately because UE4 don't support Lighting Channels as UE3.

You can place Directional Light into your level and set it to Stationary. In Level Blueprint / or Class Blueprints you can change Light Color and Brightness, but it will cause to lit all of your objects and we want to light up only hands and weapon.

For PC you can just add spot light to your character blueprint and trigger its visibility when you are shooting - it's really simple.

I will go back to this effect when Epic will release Lighting Channels.

This is how your weapon should look like:

In next post we will add another weapon - Shotgun. We will need other weapons with different functionalities to have the game more fun to play and more challenging. 

Due to refactoring I'm moving to new blog which can be found here:

See you there!