UnrealEngine4Blueprints (6)
.pdf
Step #20 In empty space near “Set “Screen XY”, right click and search the Compact Blueprint Library for “Get Player Character”. Make sure you select Character as there are a few to choose from!
Step #21 From the blue empty node of “Get Player Character”, drag to the right and in the search box, type in “Cast to MyCharacter” (Or the name of your Character blueprint!)
We’re now speaking directly to your “MyCharacter” Blueprint!
Step #22 Before we get ahead of ourselves, as I mentioned before: You cannot trigger nodes in a Blueprint without connecting them to either an Event or the main timeline of Blueprint nodes (Which are connected down the line to an Event).
So drag the left pin of our “Cast” to the right pin of “Set Screen XY”.
71
Step #23 From the blue “AsMyCharacter C” pin of our “Cast”. Drag to the right and type in “Get PortalLoader”.
We’ll need this in two seconds (Not literally), hence why we’ve called for it now.
So now we have a direct connection between the HUD, the Player and the Portal! But what can we do with this power?
Step #24 From the “Cast to MyCharacter”, drag the top empty pin to the right and type in “Branch”.
What did we just do? A branch is one of the most important Blueprint functions! It’s basically “Is this thing happening? Yes or No?”. Another way to put it would be: “This. True or False?”
Step #25 Connect the red empty pin of “PortalLoader” to the “Condition” slot of the “Branch”.
We’ve just done something seriously awesome! We’re asking the Player “Is Portal Loader true?”. Player is then asking the Portal: “Is it true?” and when the answer is yes, the Portal will tell the player to tell the HUD that it’s true.
And you made that happen! Go you!
We now need to tell the HUD what we want to do if this is true…
Step #26 From the “True” pin of “Branch”, drag to the right and type in “Draw Material” and select “Draw Material Simple”.
Step #27 On the far left of the Window, where all our Variables are stores, Drag and drop Screen XY underneath “Branch”. When it asks if you want to “Set” or “Get”, we want to get it.
72
Step #28 From the dark blue pin of “Screen XY”, drag a little to the right and search for “Break Vector 2D”.
What did we just do? Screen XY is our Screen Dimensions, which we set earlier. This will determine the how big the Material has to be to fill the whole screen.As we made it into a Vector 2D earlier (To make it easier to store), it is now time to break the Vector 2D, so we can use it with our Material.
Step #29 Drag the “X” pin of “Break Vector 2D” and slot it into “Screen W” and the “Y” pin and slot it into Screen “H”.
Step #30 In our “Draw Material Simple” node, where it says “Material: None”, click the gray arrow that is pointing down and search for your Loading Screen material.
Step #31 On the “Draw Material Simple” node, Grab the rightfacing empty Pin and drag to the right. In the Compact Blueprint Library that comes up, Search for “Open Level” and just we did earlier, type in the level name of Level #2 (For me, that’s “ArtOf_Example2”).
73
You’ve done it! Now only did you create a Portal, but now it’ll show a Loading Screen while it’s loading the next level! You rock!
Compile it and test it out if you want!
If you were using an Animated Material, I’d put a “Delay” node after the “Draw Material Simple” and before the “Open Level” and set the Delay to 2 seconds.
You did it Champ! You rock! You’ve made multiple Blueprints, made them talk and above all else Made your first few steps into not only Blueprints, but in my opinion the best game engine out there! Well done!
Use your knowledge now to create another Portal coming back to Level #1 and then Level #3
.etc! You’re one step closer to Mastering Blueprints! Go You!
74
Project #1 WrapUp!
So we not only created a working Portal from Level #1 to Level #2, but we also added a Loading Screen and learned the secrets behind the Blueprints system as well as scripting in general!
We’ve learnt about Bools, about Unreal Engine in general and we’ve learnt how to make Blueprints talk to each other!
We’re far from over in this book, there’s one more Project left to uncover, but I hope you’re feeling more confident in using Blueprints now.
We’re about to enter even more exciting territory with the next Project so hang tight!
75
Mission #2 First Blood II
Creating a SideScrolling, Multiple Characterbased Adventure
Template:
Blueprint SideScroller
What You’ll Learn:
How to kill a Player
Creating and switching between Multiple Characters.
HUD
Coin Collecting
Cutscenes
Basics of Applying a “PostProcess”
Timer System
What You’ll Need:
Photoshop / Image Editing Program (For creating HUD elements)
(Extras) What You’ll Need for Extras:
Microphone
Background Music
76
Let’s Begin… Again!
First things first, let’s fire up Unreal Engine 4 and create a new project!
If you’ve forgotten how to do this, when you open Unreal Engine 4, you’ll be greeted with the Launcher. Simply click launch and you’ll be greeted with the Project Browser.
On the top of the Project Browser, there’s a HUGE “New Project” tab. Click that and scroll through the list until you find “Blueprint Side Scroller” (Don’t pick “Code Side Scroller”!).
.
Be sure to name your Project and hit “Create Project” to begin our new adventure!
77
We’re In!
Give Unreal Engine a moment to create the project for first time use. Once it’s loaded our project, you’ll notice the game looks quite a bit different to the “Third Person Blueprint” example we used in the last Tutorial.
Be sure to hit the “Play” button just above the Editor and try out what we’ve already got It’s pretty sweet!
The adventure we’re about to embark on is going to turn this awesome project into something with even more awesome!
Take a few moments to get familiar with how the game looks and feels You’ll notice things such as the fact that everything looks like a 3D version of a 2D game. You’ll also quickly notice that the player is stuck moving along the X and Y axis, to give the illusion that this 3D game is 2D. We call this “2.5D”.
So once you’ve had a fiddle around ingame, it’s time to make some major modifications!
We’ll start off by adding a HUD, which we’ll use to count the time as well as display how many coins the player has collected!
78
HUD Prep!
We’ll need to create something that will become the HUD in an image editing program; If you can’t / don’t want to do this, I’ve included the HUD files we’ll be using in these examples in the Project samples (Available at http://content.kitatusstudios.co.uk).
We’ll need the HUD itself as well as a black and white image (Black being what ISN’T shown and white IS what should be shown.)
Here is an example of what you should end up with:
On the Left is our HUD (.PNG) and on the right is the “Opacity Mask”.
The reason the black in the “Opacity Mask” covers what we don’t want the HUD to draw. The White / Grey is what we is what we want the HUD to draw. We have to do this because I haven’t found a way for Unreal Engine 4 to take the transparency from the .PNG and so creating a dedicated Opacity Mask ignores this fact and manually sets what we want to see.
The reason in the example images I have used Grey instead of White for the example “Opacity Mask” is so that the HUD is slightly transparent (But not too much!) which means that the Player can through the HUD and not miss any important things in the level.
While we’re here, we’re going to do the same thing with our Coin image (Also included in the project files).
You should now how four files: A HUD, a coin, and the two “Opacity Mask” images (One for the HUD and one for the Coin).
Now it’s time to bring them into Unreal Engine 4!
79
HUD… HUD… And Away!
Step #1 Just like last time, create a folder in the your Content Browser Library, so we can store all our work!
In the Content Browser, with “GAME” selected, Click “New” on the top of the Content Browser and select Folder.
We’ll call this folder “Tut_FirstBlood” (Name yours what you wish!)
80
