18 Game Development and Simulation with Unreal Technology
FIGURE 1.14: A View of the Pr oject Based on Si de Scroller Template i n UE4.
it a name, and click Creat e Project in the lower right c orner (Figure 1.13).
Remember to leave the Include Starter Content selected to have the UE4
include starter contents into your project.
When the project is launch ed, you will see the example map that come s with
the side scroller tem plate. This map is designed as a platformer test map for you
to use the default side scroller character. The map is fairly large; however, the
character is only ab le to traverse left an d right from the starting position. If you
click play, you will notice that movement is only possible o n the Y and Z axes
and not the X axis.
What Happened in TUTORIAL 1.4. . .
At this point, we have successfully created a pr oject in UE4 using the side
scroller blueprint template. Let us ta ke a closer look at the MyCharacter
blueprint of this template to be tter un derstand what makes it tick.
To view the logic that gives the character movement, we must again look at
the MyCharacter blueprint. This can be accessed by locating the Con tent
Browser in the lower left corner and clicking Blueprints-> MyCharacter.
Once the MyCharacter blueprint is open, you w ill see a very simple event graph
for th e character (Figure 1.15).
In fact, this event graph only has 3 events in it, InputAxis->MoveRight,
InputAction->Jump and InputTouch . In order to move left, the character is
technically moving in a negative direction r elative to a right movement. This
means we only need one event for the Y-axis movement. The jump event simply
calls the Jump function when the spaceba r is pressed.
If you click on the Components tab in the top right corner, y ou will see the
physical components that make up the side scroller character (Figure 1.16). This
character is similar to the third-person character except for the camera setup. In
Setting up Unreal Project Templates 19
FIGURE 1.15: The MyCharacter Bl ueprint Network.
this case, the camera is raised slightly higher and is fixed in on the character. This
means that the camera position and rotation does not change when the character
moves.
When the character moves in-game, the camera moves with it at a fixed ro-
tation and distance. The camera is attached to a Spring Arm Component, which
allows us to adjust the camera distance and an gle relative to the character. For a
side scr oller, it is unlikely that the c amera will collide with a wall and have to
spring inward toward the character, but this is still accomplished by this compo-
nent if need be.
1.7 TOP-DOWN TEMPLATES
The next template we will go over is the Top-down template. A Top-down camera is
basically described in its title. Your character or envir onment is viewed from above
from a camera that generally has a fixed rotation (a lthough this is not always the
case) and a fixed angle. The UE4 Top-down template has a simple cha racter/camer a
setup to get you started in the creation of a Top-down sty le game. I n the next tutorial
we will create a proje ct using the Top-Down bluep rint template.
TUTORIAL 1.5 Creating a Project Based on Top-Down Blueprint
To create a project using the Top-down blueprin t template, simply select the
20 Game Development and Simulation with Unreal Technology
FIGURE 1.16: The Components of HeroTPP Side Scroller Blueprint.
template under the New Project tab in the Unreal Project Browser window.
Select th e Blueprint ta b and find the Top-Down template icon. Give it a name
and select Create Project.
After you select Create Project, you will be greeted with the example map
package d in the top-Down template. Clickin g Play will allow you to jump into
the game and take control of your Top-down characte r.
You may notice that th e standard keys from the third person and first per-
son templates (‘W’,‘A’,‘ S’,‘D’) do not actually control the character in the Top-
down template. This character is controlled by mouse clicks. By clicking any-
where on the floor of the ma p, your character will automatically run to the lo-
cation of the mouse click. Clicking again will change the character’s path. By
holding the mouse button down, you can even have the path of the char acter
update endlessly and your character will constantly follow the tip of the mouse
cursor.
What Happened in TUTORIAL 1.5. . .
In this tutorial we simply created a project using the Top-down blueprint tem-
plate. Let u s take a lo ok under the hood of this template to see what is actually
going on.
If you followed along w ith the first person and thir d person tutorials, you
might think that our char acter functionality will be located inside the MyChar-
Setting up Unreal Project Templates 21
FIGURE 1.17: A View of the P roject Based on t he Top-Down Template in UE4.
acter blueprint. However, th e Top-down template is actually quite a bit different.
The Components section for the Top-d own MyCharacter blueprint should
look similar to the MyCharacter blueprint from the third person template. The
most noticeable difference is the p la cement of the camera. This particular camera
is po sitioned to give us a Top-down view of the character that we will be control-
ling in the game. The camera is attached to a spring arm but in this case, to have
a fixed rotation while the character is walking around in game ( see Figure 1.18).
Of cou rse, since the MyCharacter blueprin t has no functionality in the event
graph, we must be getting our movement logic from somewhere else. In this case,
we get our movement logic from a blueprint called MyController.
Before o pening the MyController blueprint fr om the Con te nt Browser,
mouse over the icon to view some of its properties. These properties will tell you
the path to the particular a sset, as well as other useful information. In this case,
we can note that the parent class for this blueprint is of type PlayerController.
By using this as a parent class, we will inherit all the attributes that make up a
PlayerController into our own class blue print. In other words, MyController
is the class b lueprint that is giving our character the ability to move around in
game.
When the MyController Blueprin t is opened, go to the Graph tab to view
our character’s functionality (see Event Graph tab in Figure 1.19). T his may be
a little complicated at first glance so let us go over it bit by bit.
22 Game Development and Simulation with Unreal Technology
FIGURE 1.18: Blueprint Top-Down Character BP and Camera Placement View.
FIGURE 1.19: Blueprint of the Controller in a Top-Down Project.
The cluster of nodes in Figure 1.19 begins with an Event Tick the red
node on the upper left corner of the canvas. Event Tick is a function that will
fire once every iteration of the core game loop. In every game with real-time
graphics, th ere is a core game loop in which the graphics are rendered over and
over again as long as the game is playing. This means the graphics on screen are
updated c onstantly. The spee d at which this occurs depends on many different
things includ ing the speed of the machine that is running the code. Just know
that for every frame rendered on the screen, this event tick function will fire.
After the Event Tick is fired, we check for input from a mouse as well as
input from a touchscreen, which is generally used for mobile platforms. This is
done using a sequence gate. The first sequence must completely finish before the
next sequence is called. We move fro m a sequence gate to another gate function
that allows us to open and close the flow based on the input from the mouse.
..................Content has been hidden....................

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