Welcome back.
We're now ready to tie all this together.
We have a player controller blueprint.
We have a character.
And the way to tie these all together is through the game mode.
So I'd like to be able to set the game mode in the world settings for our level here, and that will
determine our default pawn class and our player controller class as well as all the other classes once
we start configuring functionality for those.
So I'd like to make a C plus plus class for our game mode just so we can have that C plus plus backbone
and then we can make a blueprint based on that.
So I'm going to go to my C plus plus classes aura public folder and make a new C plus plus class here.
And I'm going to choose game mode base as I don't need the game mode class.
The game mode base class is more basic and it has all that we need, so I'm going to choose that.
And I'm going to place this in a folder called Game.
So we're keeping ourselves organized here.
And I'll call this Aura game mode base.
We'll call the C plus plus class or a game mode base.
So we know that this is a game mode base.
Let's go ahead and create the class.
I'll click No and close the editor so that I can end up compiling from my IDE.
And here is or a game mode base in my game folder.
Perfect.
Now I'd like to actually set up the blueprint so that I can finally playtest.
So I'm going to go ahead and run in debug mode.
And now with our editor open, I can go ahead and open my aura player controller if I like, but what
I'm interested in doing is making a blueprint based on the game mode or a game mode base.
So I'm going to go to the blueprints folder and make a new folder here called Game, and that's where
we'll store our game mode.
So right click Blueprint class and I'll search for Aura game mode.
And here's our A game mode base.
We'll select that and I'll call this BP or a game mode.
Now I'm going to open that and set a couple things.
For one, we have a player controller class.
We can set that to BP or a player controller, and we also have the default pawn class.
I'll set that to BP or character.
Now that those are configured, I'm going to save and close my game mode.
I can close my player controller blueprint as well.
And here in our startup map, I'm going to set the game mode override to BP ora game mode so that those
classes will be used.
And I'm also going to want a player start here that will determine where we spawn.
So I'll go ahead and open up this dropdown here.
Go to basic and choose Player Start.
I can click and drag one in and I'll have one right there.
And now if I press play, we've spawned in the Ora character where possessing that ora character and
we don't have a camera or spring arm.
So in order to really see the character, I have to detach and move away from the character.
But there she is, there's Ora, and we know that we're possessing Ora.
If I attach again and click in the viewport, I can press w.
ASD and we see that we're moving.
The only problem of course, is that well, we're stuck right here on aura directly.
We need a camera and a spring arm component for this to really look good.
And that's going to be your quest.
I'd like you to create a camera and spring arm component and put that on aura and make the decision,
Are you going to do this in C plus, plus or blueprint?
Now, think about this.
Do you need it in C plus plus?
Can you see an immediate need for having those in C plus plus?
Or can you just add them in blueprint and then think about the parameters.
What's your target arm length for the spring arm and what other parameters are you going to set for
the camera?
So I'd like you to make these decisions.
I'll give you a bit of a spoiler.
I'm going to use Blueprint to add the spring arm and the camera component.
But again, make the decision for your project and add these components.
So pause the video and conquer this quest.
Okay, so we need a camera and a spring arm, and I'm going to choose to do this in blueprint.
I don't see an immediate need to have a camera and spring arm component set up in C plus plus.
It's actually much quicker to do it in blueprint and we get no performance benefits doing it in C plus
plus while the game is running.
It's not going to matter whether it was set up in one domain or the other.
So I'm going to set it up here in blueprint.
So showing the viewport so I can see my character and their mesh.
I'm going to select my capsule component.
That's the route I'd like my spring arm attached to that.
So I'm going to click Add and search for Spring Arm and add that and I can let that be called Spring
Arm.
No need to rename it.
And with the spring arm selected, I'm going to add a camera.
So selecting camera and there's my camera component and I can configure this now.
So let's think about the settings that we really want for this.
This is a top down game, so I'd like it to be angled somewhat downward.
So selecting that spring arm, I'm going to disable, snapping and adjust the rotation for it.
So I'm going to press the key and rotate.
And the angle for this really just depends on your preference.
We can just go for a straight 45 degree angle.
It's actually -45 if you want.
I'm going to give that a try.
And for the target arm length, I'm going to adjust it here.
I'm going to bring it out probably up to about 6 or 700, maybe 750.
But we'll see how that looks.
Now scrolling down, I see that I have used pawn control rotation unchecked.
I do want that unchecked.
I don't want to rotate the spring arm with the controller, although we don't really plan on changing
the controller's orientation at all.
For a top down, the camera will be fixed.
Now, if you like, you can have some camera lag.
That's a nice little effect that lets the camera sort of lag behind a little bit.
That's up to you if you want that feature.
Now for the camera itself, I'm going to search for control and make sure use pawn control rotation
is set to false and that way our camera will truly be fixed.
Okay, so now that we have a camera and spring arm, I'm going to save all and press play.
And there's my character.
I can click in the viewport and I see that I can move.
Now.
The only thing that's looking a little funny here is that our character is not orienting towards movement.
So there's a few things that we can configure for our character.
Before we wrap up the video, I'd like to close the editor and set some of these properties on our character
class or a character, and to do that, I'm going to want a constructor for a character.
So I'm going to go into or a character dot H Now I'm in or a character dot CP here.
If you're in writer and you have Visual Studio Shortcuts, you can use control k o to open the header
file, but also writer has alt o to open the header file as well.
And here in ora character I'm going to add a public section.
And we'll add here a constructor and we'll generate a definition for the constructor.
And I'm just going to set up a few parameters here so our character behaves the way we want it to.
First, I'm going to get the character movement component with get character movement.
And from this I'm going to access be Orient rotation to movement and set that to true.
Now we can control the rotation rate with get character movement rotation rate.
And this is something that I think should be really tweaked in the editor, but we can give it a default
value here of zero point F, 400 f and zero dot f, and that way our character will orient towards movement
with this speed, at least in the yaw rotational direction.
Now, character movement can force us to constrain our movement to a plane.
This is what we would want to do for a top down game.
So we do that with get character movement, be constrained to plane.
We can set that to true and we can also ensure that our character is snapped to a plane.
When we start with get character movement, be snap to plane at start, we can set that to true.
So these are typical parameters for a top down game.
Now our character itself should not use the controller's rotation, so we're going to set B use controller
rotation pitch to false and we'll do the same thing for the other rotational variables.
We'll set all of these to false B use controller rotation, pitch, roll and yaw.
All of these will be false.
Okay.
So now that we've got this all set up, let's go ahead and play test.
I'm going to hit debug.
We'll run in debug mode.
I'll go ahead and open those assets that were open before, namely or a character.
And we can go ahead and press play and move around.
I'm going to click in the viewport.
And it looks like my camera is rotating.
And that's not what I want.
I want a fixed camera.
So here in the spring arm, I'm going to uncheck, inherit, pitch, yaw and roll.
And now we see that our spring arm is not inheriting the pitch yaw or roll.
And that's the behavior that I want.
Now, one thing I don't like is when I stop moving, I see your head jerk back and forth a little bit
like that.
And I'm going to fix that by opening the animation blueprint.
And here in Maine states, our idle walk run blend space can be used, but I'd like to only use it if
we're running.
I'd like another state here for simply idle.
And in fact, we can call this running instead.
And what I'll do is just make the entry go into idle and we'll only go into running if we should move.
So Idle will simply have the idle animation.
We'll drag that in.
And then for idle to running and running back to idle, we'll just use a simple boolean called Should
Move.
So back in the event graph, I'll click add, we'll add a variable called Should Move and we'll set
this here.
I'm going to set it if ground speed is small, almost zero.
So I'm going to say if ground speed is less than some small value, say three.
I don't want it.
Exactly.
Zero.
Then we'll set.
Should move.
And we'll only set it if ground speed is less than zero.
So this will be set like this and we'll check.
Should move to transition from idle to running.
So from idle to running we'll use should move and from running to idle we'll use should move but using
a not boolean.
That way, we'll transition back if we should not move.
And of course, that actually means that should move should be false if ground speed is less than three.
Right.
So we can actually change this to greater than.
Should move should be true if speed is greater than three.
And before we test this out, I'm going to go back into main states and go into idle and select the
idle sequence player and make sure to check loop animation as we want that idle animation to be looping.
Let's try this out.
There we go.
And we don't get that head jerk because now we're just going back to the idle state.
And will only use the blend space if we're actually running.
Perfect.
All right.
So now that we have movements, we have a game mode.
We're almost done setting up the basics for this project, and then we'll move on to what we're really
here for, which is the gameplay ability system.
And that's where things are going to get really interesting.
So great job.
Just a couple more things to set up before we close out this section and move on to the interesting
stuff.
I'll see you soon.