The sounds of our explosion are all in place and the Artifact is ready for destruction! To finish our explosion, we are going to need some particle effects. We used various particle effects back in Chapter 5, Taking This Level Up a Notch, to enhance our scripted events at the security checkpoint and the elevator. Here we will use an explosion, fire, and smoke to enhance the destruction effect and mask when we delete the different components of the Artifact. Let's take a look:
To our already extensive list of components, we will add explosion, fire, and smoke particle emitters. Add each emitter, just like we added our sound, and then select each one and disable the Auto Activate option in the Details panel. We will use the Blueprint node Activate to turn those back on later.
The last piece necessary to really make this explosion great is to add flying chunks! When a solid object explodes, parts of it tend to go flying in all directions. We will simulate this by having our Blueprints spawn versions of the bottom and the top of the Artifact, with physics enabled, which will fly around and stay in the level after the rest of the Artifact has been destroyed:
Blueprint
for each new static mesh by clicking the Blueprint button, selecting New Empty Blueprint Class, and selecting Actor as the Parent Class. I named mine ArtifactTopChunk
and ArtifactBotChunk
.50
kg, but feel free to use whatever you wish. It can always be adjusted later. Be sure to do this for both the Top and Bottom Artifact chunks.Time to finish the Artifact's demise. Back in the Artifact class Blueprint, there is one more Component to add to our setup. To make our Top and Bottom chunks fly, we will use a Radial Impulse component to simulate the force of the blast. Add the Radial Impulse through the Add Component menu and find the Radial Force Component section of the Details panel. The radius that the impulse will affect is shown in the viewport as a light blue sphere. Increase the size of the Radius property until it covers the entire Artifact. I used 250
. Also in the Details panel, find the Impulse section and increase the Impulse Strength. I used 2000
. Lastly, make sure to turn on the Impulse Vel Change option. This option makes sure that the 2000 units of force are applied directly as a velocity change. This will guarantee to throw our chunks a good distance and maybe even the player!
Time for the last bit of programming! Let's take a look:
There isn't too much to this final section. We will use a second Activate node off the end of the countdown section to activate all of our particle effects. Then use a Destroy Component node to get rid of the components that would be destroyed in the blast. Next, we will use two Spawn Actor From Class nodes to spawn our two chunks, before finally using a Fire Impulse node to throw them away from the blast. Lastly, we will Delay 4 seconds before using a Destroy Actor to clean up the whole thing. Start by using the search box in the Palette to grab the Activate node. Place it at the end of the countdown sequence and connect it to the Activate node we used to play our sound cue. The Activate node needs one or more Targets to know what to turn on. From the Components panel grab the P_Explosion, P_Smoke, and P_Fire components and drag them into the Blueprint. Connect these to Target node on the Activate node.
Next in line is the Destroy Component node. We will use this node to delete everything that would be destroyed in the explosion. Connect it to our Activate node and set its Targets to be the Artifact, the collision box, and all the tentacles.
Time for Spawn Actor From Class! This great node allows us to use Blueprints to spawn other class Blueprints, but requires a few more parameters than Activate or Destroy Component.
Place the Spawn Actor From Class node next to the Destroy Component node and link them. The first thing we need to tell it is what class to spawn. Click the drop-down box and select the bottom Artifact chunk. The second thing it needs to know is where to spawn. This can be done by plugging a Get Actor Transform node (found using the search box in the Palette) into the Spawn Transform option. Now we are set to spawn! Repeat this step to set up a Spawn Actor From Class node for the top Artifact chunk.
Now fire that Radial Impulse and make this a true explosion!
The node we need to use is Fire Impulse. The only thing this node needs is a Target. Grab our Radial Impulse component from the Components panel and plug it in.
To wrap things up we just need to do a little bit of housekeeping. At the end of this sequence, add a Delay and a Destroy Actor node. The Delay will be set to 4.0
seconds to give our sounds time to play, and the Destroy Actor will have Self as a Target. This will remove all of the class Blueprint from the level. However, it will leave the exploded chunks behind. Even though we used a class Blueprint to spawn them, they are separate Actors and will not be deleted when the rest of the class Blueprint
deletes itself.
Make sure the sequence is connected up in order and test it. You should have a satisfying explosion that throws pieces of the Artifact around. If the player is too close, it will even throw them backward!
Explosions are so much fun to make and can be a great way to add a bit of action to any experience, but if you had fun building this sequence, you don't need to stop here. Try adding more explosion particle effects, or adding the tentacles as chunks for added effect.
How oddly satisfying was that?! There is just something about building something amazing for a video game and then allowing our player to blow it up. With our game asset now properly set up, we can place it in our space station level and use it as a goal to drive our gameplay forward. In this chapter, we went through the process of bringing our fully textured and animated Artifact in to Unreal and setting it up to look great in the level. We used a class Blueprint setup to assemble the pieces and created a way for the player to interact with it, causing it open. We then added some additional components and programming that allowed the player to start a countdown and blow up our game asset in a fine display of fire, smoke, and flying chunks.
And with that, we are done! Congratulations on finishing the book! What you have created is a great skeleton of a game that can be expanded on to create something amazing and uniquely your own. You have two whitebox levels that can be filled with your own custom art created in Blender. You have two game assets that can be further customized to fit your game's specific needs. I would strongly encourage you to properly finish each of these levels and to keep practicing and polishing your skills. Become the game designer or game artist that you want to be and I truly look forward to playing your unique games in the future!
Stick with it and game on!
3.16.79.147