614 Game Development and Simulation with Unreal Technology
These two tasks were then, in turn, programmed in the sequence of behaviors
in the behavior tree. This will make our AI characte rs b e able to perceive the
location of the playe r and to actively attempt to seek the player.
The game is really coming along well. If you play the game now, your AI enemy
characters should spawn and chase the player. Each enemy should take dam age and
get destroyed when the player projectiles hit it. The player projectiles sho uld also
destruct when they hit an enemy or a wall. And the pla yer should die if it is hit
multiple times by an enemy.
9.9 PARTICLE SYSTEMS AND VISUAL EFFECTS
So far we have implemented a great deal of functionality into our game, but th e
destruction of the enemy, player, and bullets are kind of anti-climactic! We will fix
this issue by im plementing a couple of particle effects in the next set of tutorials.
9.9.1 DESTRUCTION VISUAL EFFECTS
In the next tutorial we will implement the visual effects for when the player and
the ene my are destroyed. This will involve spawning a particle system actor at the
location where the destruction happens.
FIND ON THE WEBSITE
To find updates to this tutorial and upda te d instructions about its implementa-
tion on othe r UE4 versions, p le ase visit the books companion Website at:
http://www.RVRLAB.com/UE4Book/
TUTORIAL 9.13 Destruction Visual Effects
In this tutorial we will implement a visual effect for when our enemy and player
are destroyed.
SETTING ENEMY DEATH VISUAL EF FECTS
To establish a visual effect for the enemy destruction event, we will spawn a fire
particle system at the location where the enemy is destroyed.
1. Go to the Enemy blueprint’s Event Graph.
2. Drag node off the Destroy Actor node.
3. Search and pla ce the Spawn Emitter at Loc ation.
4. Set the Emitter Template to P_Explosion.
A Top-Down Game with Blueprints 615
FIGURE 9.45: The Network for Enemy Death Particle Effect.
5. Right-click to the left of the Spawn Emitter at Location and add a G et Actor
Location.
6. Connect return value of the Get Actor Location to the Location channel of the
Spawn Emitter at Location (see Figure 9.45).
SETTING THE PLAYER DE ATH VISUAL EFFECTS
We will perform a similar activity for when the player is destroyed. However, we
will also spawn an exp losion particle system for the player to make th e playe rs
destruction sequence a little more drama tic.
7. Go into the RotationChar Event Graph.
8. Drag node off the Destroy Actor node.
FIGURE 9.46: Player’s Destruction Sequence Particle System Network.
9. Add a new Spawn Emitter at Location to connect it to the Destroy Actor.
616 Game Development and Simulation with Unreal Technology
10. Set the Emit ter Template to P_Fire.
11. Right-click to th e left of the S pawn Emitter at Location and add a Get Actor
Location.
12. Connect return value o f the Get Actor Location to the Location channel of the
Spawn Emitter at Location.
13. From the Spawn Emitter at Loca tion node dr ag off a new Set Relative Scale
3D node.
14. Set the Re turn Value of the P_Fire Spawn Emitter at Location node to the
target of the Set Relative Scale 3D node. Note: You may have to uncheck the
Context Sensitive option to be able to search for this node.
15. Enter the New Scale 3D values of 5.0, 5.0, 5.0, for X , Y, and Z, respectively.
16. From the Set Relative Sc ale 3D node drag off another Spawn Emitter at
Location node.
17. Set the Emit ter Template o f the second emitter to P_Explosion.
18. Add another Relative Sc ale 3D to the right of the second explosion emitter we
just created.
19. Set the Return Val ue of the P_Explosion Spawn Emitter at Location node
to the target of the second Set Relative Scale 3 D node. No te : You may have to
uncheck the Co ntext Sensitive option to be able to search for this node.
20. Enter th e second New Scale 3D values to 5.0, 5.0, 5.0, for X, Y, and Z, re spec-
tively (see Figure 9.46).
21. Compile and save yo ur blu eprints and your progre ss so far.
22. You can te st drive and see how the player explodes and catches on fire after its
destruction.
What Happened in TUTORIAL 9.13. . .
In this tutorial we set up a mechanism to spawn a particle system whenever th e
player and the enemy die. This will give us a b etter visual effec t to convey to the
player, visually, when an enemy actor is destroyed or when the player actor is
destroyed.
We chose a particle system from the S tarter Content that simulates the
effects of an explosion. We used the destroyed actors location as the spawning
location for our visual e ffect. We also need to m odify the scale of the particle
system to represent the appropriate sizes of the player and the e nemy actors and
the explosion they should create when they are destroyed.
9.9.2 HIT VISUAL EFFECTS
Let us implement some visual effects to enhance our g ame. We want to have the
bullets to burst some spa rks when they h it an enemy or the walls. To do this we will
set up a mechanism to spawn sparks particle systems when a hit event occurs. We
A Top-Down Game with Blueprints 617
will also make the player and enem y flash with a bright material when they are hit to
visualize the effect of taking damage.
FIND ON THE WEBSITE
To find updates to this tutorial and u pdated instructions about its implementa-
tion on other UE 4 versions, please visit the books companion Website at:
http://www.RVRLAB.com/UE4Book/
TUTORIAL 9.14 Projectiles’ Hit Visual Effects
In this tutorial we will establish a particle system for when a projectile hits a
wall o r an enemy to create a spark effect.
SETTING PROJECTILES’ HIT VISUAL EFFECTS
We will first make minor modification s to our Spark Emitter in the Cascade
Particle Editor.
1. Go into the main ed itor and in the content br owser look through the starter con te nt
until you find the particle effect c alled P_Sp arks.
2. Right-click this and duplicate it. Name this duplicate Impac tSparks. Note: we
will be duplicating the ImpactSparks later on after we edit its values.
3. Double-click the ImpactS parks to ope n it up.
4. In the CASCADE particle editor, click on the Smoke emitter to select it and press
delete on your keyboard to remove it.
5. At this stage you should have two emitters Sparks a nd Spark burst (see Fig-
ure 9.47(a)).
(a) (b)
FIGURE 9.47: (a) The Spark Emitter and Its Modules. (b) The Sparks’ Color Over Life
Graph.
618 Game Development and Simulation with Unreal Technology
6. On the Sparks emitter click on the small gra ph icon next to Color over Life. This
will open up the graph of this par ameter in the Curve Editor just below the
Emitters section.
7. In th e Curve Editor click on the small yellow b oxes on the LifeMultiplier
channel and AlphaOverLife to hide their values from the curve editor (see Fig-
ure 9.47(b)).
WORKING WITH SPARKS
Let us make some changes to the Color Over Life and A lpha Over Life
distribution to make them suitable for our purpose.
(a) (b)
FIGURE 9.48: (a) Color Over Life Distri bution. (b) Color Over Life Values.
8. Make sure Color Over Life is still selected and in the Details rollout expand
Color Ov er Life Distribution Constant Curve.
9. Make sure y ou have 2 elements for Points a ttribute for the Constant Curve (see
Figure 9.48(a)).
10. Expand Points 0 an d Points 1.
11. To make the sparks shine with a close similar to the color of our projectile, in the
Points[0] and Points[1], make the following changes (see Figure 9.48(b)):
Points [0] Points [1]
In Val 0.0 In Val 1.0
Out Val X 1.0 Y 20.0 Z 0.0 Out Val X 0.0 Y 3.0 Z 0.0
12. Now, select the Alpha Over Life and in the Details rollout expand Alpha Over
Life Distribution Constant Curve.
13. Make su re you have 2 elements for Point s attribute for th e Constant Curve (see
Figure 9.49(a)).
14. Expand Points 0 an d Points 1.
15. To make the sparks disappear much more quickly, in the Points[0] and Points[1],
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.146.176.145