WEBVTT

00:06.990 --> 00:08.100
Welcome back.

00:08.520 --> 00:10.770
We're now ready to tie all this together.

00:10.770 --> 00:12.870
We have a player controller blueprint.

00:12.900 --> 00:14.430
We have a character.

00:14.430 --> 00:17.910
And the way to tie these all together is through the game mode.

00:18.120 --> 00:24.540
So I'd like to be able to set the game mode in the world settings for our level here, and that will

00:24.540 --> 00:31.410
determine our default pawn class and our player controller class as well as all the other classes once

00:31.410 --> 00:34.350
we start configuring functionality for those.

00:34.350 --> 00:41.490
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

00:41.490 --> 00:43.980
and then we can make a blueprint based on that.

00:44.160 --> 00:51.000
So I'm going to go to my C plus plus classes aura public folder and make a new C plus plus class here.

00:51.000 --> 00:56.280
And I'm going to choose game mode base as I don't need the game mode class.

00:56.280 --> 01:02.370
The game mode base class is more basic and it has all that we need, so I'm going to choose that.

01:03.210 --> 01:07.580
And I'm going to place this in a folder called Game.

01:07.590 --> 01:10.050
So we're keeping ourselves organized here.

01:10.050 --> 01:14.310
And I'll call this Aura game mode base.

01:14.310 --> 01:18.150
We'll call the C plus plus class or a game mode base.

01:18.150 --> 01:20.820
So we know that this is a game mode base.

01:21.030 --> 01:22.860
Let's go ahead and create the class.

01:22.890 --> 01:28.710
I'll click No and close the editor so that I can end up compiling from my IDE.

01:29.160 --> 01:34.050
And here is or a game mode base in my game folder.

01:34.050 --> 01:35.160
Perfect.

01:35.160 --> 01:40.800
Now I'd like to actually set up the blueprint so that I can finally playtest.

01:40.800 --> 01:43.140
So I'm going to go ahead and run in debug mode.

01:43.410 --> 01:50.520
And now with our editor open, I can go ahead and open my aura player controller if I like, but what

01:50.520 --> 01:56.340
I'm interested in doing is making a blueprint based on the game mode or a game mode base.

01:56.340 --> 02:01.560
So I'm going to go to the blueprints folder and make a new folder here called Game, and that's where

02:01.560 --> 02:03.340
we'll store our game mode.

02:03.340 --> 02:08.740
So right click Blueprint class and I'll search for Aura game mode.

02:09.930 --> 02:11.700
And here's our A game mode base.

02:11.700 --> 02:15.570
We'll select that and I'll call this BP or a game mode.

02:15.960 --> 02:19.470
Now I'm going to open that and set a couple things.

02:19.470 --> 02:22.080
For one, we have a player controller class.

02:22.080 --> 02:28.350
We can set that to BP or a player controller, and we also have the default pawn class.

02:28.380 --> 02:31.640
I'll set that to BP or character.

02:31.650 --> 02:36.360
Now that those are configured, I'm going to save and close my game mode.

02:36.360 --> 02:39.300
I can close my player controller blueprint as well.

02:39.300 --> 02:47.490
And here in our startup map, I'm going to set the game mode override to BP ora game mode so that those

02:47.490 --> 02:49.470
classes will be used.

02:49.500 --> 02:54.180
And I'm also going to want a player start here that will determine where we spawn.

02:54.180 --> 02:57.660
So I'll go ahead and open up this dropdown here.

02:57.690 --> 03:00.960
Go to basic and choose Player Start.

03:00.990 --> 03:04.860
I can click and drag one in and I'll have one right there.

03:04.860 --> 03:13.330
And now if I press play, we've spawned in the Ora character where possessing that ora character and

03:13.330 --> 03:15.670
we don't have a camera or spring arm.

03:15.670 --> 03:21.160
So in order to really see the character, I have to detach and move away from the character.

03:21.160 --> 03:25.930
But there she is, there's Ora, and we know that we're possessing Ora.

03:25.930 --> 03:32.080
If I attach again and click in the viewport, I can press w.

03:33.100 --> 03:35.920
ASD and we see that we're moving.

03:35.920 --> 03:40.900
The only problem of course, is that well, we're stuck right here on aura directly.

03:40.900 --> 03:45.930
We need a camera and a spring arm component for this to really look good.

03:45.940 --> 03:47.800
And that's going to be your quest.

03:47.830 --> 03:54.850
I'd like you to create a camera and spring arm component and put that on aura and make the decision,

03:54.850 --> 03:57.520
Are you going to do this in C plus, plus or blueprint?

03:57.550 --> 03:58.990
Now, think about this.

03:59.020 --> 04:01.630
Do you need it in C plus plus?

04:01.660 --> 04:05.020
Can you see an immediate need for having those in C plus plus?

04:05.020 --> 04:09.380
Or can you just add them in blueprint and then think about the parameters.

04:09.400 --> 04:14.920
What's your target arm length for the spring arm and what other parameters are you going to set for

04:14.920 --> 04:15.820
the camera?

04:15.820 --> 04:18.330
So I'd like you to make these decisions.

04:18.340 --> 04:19.780
I'll give you a bit of a spoiler.

04:19.780 --> 04:24.100
I'm going to use Blueprint to add the spring arm and the camera component.

04:24.100 --> 04:28.930
But again, make the decision for your project and add these components.

04:28.930 --> 04:31.870
So pause the video and conquer this quest.

04:34.860 --> 04:40.900
Okay, so we need a camera and a spring arm, and I'm going to choose to do this in blueprint.

04:40.920 --> 04:47.840
I don't see an immediate need to have a camera and spring arm component set up in C plus plus.

04:47.850 --> 04:55.170
It's actually much quicker to do it in blueprint and we get no performance benefits doing it in C plus

04:55.170 --> 04:57.150
plus while the game is running.

04:57.150 --> 05:01.820
It's not going to matter whether it was set up in one domain or the other.

05:01.830 --> 05:04.100
So I'm going to set it up here in blueprint.

05:04.110 --> 05:09.510
So showing the viewport so I can see my character and their mesh.

05:09.510 --> 05:11.940
I'm going to select my capsule component.

05:11.940 --> 05:15.330
That's the route I'd like my spring arm attached to that.

05:15.330 --> 05:21.960
So I'm going to click Add and search for Spring Arm and add that and I can let that be called Spring

05:21.960 --> 05:22.230
Arm.

05:22.230 --> 05:23.730
No need to rename it.

05:23.730 --> 05:27.510
And with the spring arm selected, I'm going to add a camera.

05:27.780 --> 05:34.420
So selecting camera and there's my camera component and I can configure this now.

05:34.420 --> 05:37.900
So let's think about the settings that we really want for this.

05:37.930 --> 05:43.780
This is a top down game, so I'd like it to be angled somewhat downward.

05:43.780 --> 05:51.340
So selecting that spring arm, I'm going to disable, snapping and adjust the rotation for it.

05:51.490 --> 05:55.540
So I'm going to press the key and rotate.

05:55.540 --> 06:00.010
And the angle for this really just depends on your preference.

06:00.010 --> 06:03.310
We can just go for a straight 45 degree angle.

06:03.310 --> 06:06.070
It's actually -45 if you want.

06:06.070 --> 06:07.630
I'm going to give that a try.

06:07.630 --> 06:11.140
And for the target arm length, I'm going to adjust it here.

06:11.140 --> 06:17.650
I'm going to bring it out probably up to about 6 or 700, maybe 750.

06:17.650 --> 06:19.720
But we'll see how that looks.

06:19.960 --> 06:24.970
Now scrolling down, I see that I have used pawn control rotation unchecked.

06:24.970 --> 06:26.710
I do want that unchecked.

06:26.710 --> 06:32.770
I don't want to rotate the spring arm with the controller, although we don't really plan on changing

06:32.770 --> 06:35.290
the controller's orientation at all.

06:35.290 --> 06:38.170
For a top down, the camera will be fixed.

06:38.500 --> 06:41.950
Now, if you like, you can have some camera lag.

06:41.980 --> 06:46.990
That's a nice little effect that lets the camera sort of lag behind a little bit.

06:46.990 --> 06:49.320
That's up to you if you want that feature.

06:49.330 --> 06:56.560
Now for the camera itself, I'm going to search for control and make sure use pawn control rotation

06:56.560 --> 07:01.150
is set to false and that way our camera will truly be fixed.

07:01.450 --> 07:08.170
Okay, so now that we have a camera and spring arm, I'm going to save all and press play.

07:08.170 --> 07:09.940
And there's my character.

07:09.940 --> 07:14.140
I can click in the viewport and I see that I can move.

07:14.170 --> 07:14.470
Now.

07:14.470 --> 07:20.620
The only thing that's looking a little funny here is that our character is not orienting towards movement.

07:20.650 --> 07:23.590
So there's a few things that we can configure for our character.

07:23.590 --> 07:31.450
Before we wrap up the video, I'd like to close the editor and set some of these properties on our character

07:31.450 --> 07:38.170
class or a character, and to do that, I'm going to want a constructor for a character.

07:38.170 --> 07:43.810
So I'm going to go into or a character dot H Now I'm in or a character dot CP here.

07:43.810 --> 07:50.980
If you're in writer and you have Visual Studio Shortcuts, you can use control k o to open the header

07:50.980 --> 07:55.930
file, but also writer has alt o to open the header file as well.

07:56.200 --> 08:00.340
And here in ora character I'm going to add a public section.

08:01.030 --> 08:08.080
And we'll add here a constructor and we'll generate a definition for the constructor.

08:08.230 --> 08:17.170
And I'm just going to set up a few parameters here so our character behaves the way we want it to.

08:17.200 --> 08:21.730
First, I'm going to get the character movement component with get character movement.

08:22.240 --> 08:28.090
And from this I'm going to access be Orient rotation to movement and set that to true.

08:28.420 --> 08:35.710
Now we can control the rotation rate with get character movement rotation rate.

08:35.920 --> 08:42.430
And this is something that I think should be really tweaked in the editor, but we can give it a default

08:42.430 --> 08:52.780
value here of zero point F, 400 f and zero dot f, and that way our character will orient towards movement

08:52.780 --> 08:57.940
with this speed, at least in the yaw rotational direction.

08:58.030 --> 09:03.770
Now, character movement can force us to constrain our movement to a plane.

09:03.770 --> 09:06.380
This is what we would want to do for a top down game.

09:06.380 --> 09:11.120
So we do that with get character movement, be constrained to plane.

09:11.300 --> 09:18.170
We can set that to true and we can also ensure that our character is snapped to a plane.

09:18.170 --> 09:25.040
When we start with get character movement, be snap to plane at start, we can set that to true.

09:25.040 --> 09:28.720
So these are typical parameters for a top down game.

09:28.730 --> 09:35.810
Now our character itself should not use the controller's rotation, so we're going to set B use controller

09:35.810 --> 09:42.320
rotation pitch to false and we'll do the same thing for the other rotational variables.

09:42.320 --> 09:47.900
We'll set all of these to false B use controller rotation, pitch, roll and yaw.

09:47.930 --> 09:50.300
All of these will be false.

09:50.990 --> 09:51.800
Okay.

09:52.010 --> 09:56.480
So now that we've got this all set up, let's go ahead and play test.

09:56.480 --> 09:57.800
I'm going to hit debug.

09:57.800 --> 09:59.360
We'll run in debug mode.

10:00.070 --> 10:05.440
I'll go ahead and open those assets that were open before, namely or a character.

10:05.440 --> 10:10.090
And we can go ahead and press play and move around.

10:10.090 --> 10:11.620
I'm going to click in the viewport.

10:12.710 --> 10:16.970
And it looks like my camera is rotating.

10:18.340 --> 10:19.430
And that's not what I want.

10:19.450 --> 10:20.870
I want a fixed camera.

10:20.890 --> 10:25.480
So here in the spring arm, I'm going to uncheck, inherit, pitch, yaw and roll.

10:28.090 --> 10:33.550
And now we see that our spring arm is not inheriting the pitch yaw or roll.

10:33.550 --> 10:35.440
And that's the behavior that I want.

10:36.330 --> 10:41.850
Now, one thing I don't like is when I stop moving, I see your head jerk back and forth a little bit

10:41.880 --> 10:42.660
like that.

10:42.660 --> 10:47.670
And I'm going to fix that by opening the animation blueprint.

10:47.670 --> 10:54.720
And here in Maine states, our idle walk run blend space can be used, but I'd like to only use it if

10:54.720 --> 10:55.620
we're running.

10:55.620 --> 10:59.460
I'd like another state here for simply idle.

10:59.550 --> 11:03.900
And in fact, we can call this running instead.

11:03.900 --> 11:10.530
And what I'll do is just make the entry go into idle and we'll only go into running if we should move.

11:10.530 --> 11:13.530
So Idle will simply have the idle animation.

11:13.530 --> 11:14.850
We'll drag that in.

11:14.850 --> 11:21.630
And then for idle to running and running back to idle, we'll just use a simple boolean called Should

11:21.630 --> 11:22.250
Move.

11:22.260 --> 11:28.920
So back in the event graph, I'll click add, we'll add a variable called Should Move and we'll set

11:28.920 --> 11:29.790
this here.

11:29.790 --> 11:34.140
I'm going to set it if ground speed is small, almost zero.

11:34.140 --> 11:40.450
So I'm going to say if ground speed is less than some small value, say three.

11:41.140 --> 11:41.680
I don't want it.

11:41.680 --> 11:42.310
Exactly.

11:42.310 --> 11:43.000
Zero.

11:43.030 --> 11:44.470
Then we'll set.

11:44.470 --> 11:45.640
Should move.

11:47.110 --> 11:50.440
And we'll only set it if ground speed is less than zero.

11:50.440 --> 11:54.070
So this will be set like this and we'll check.

11:54.100 --> 11:57.010
Should move to transition from idle to running.

11:57.010 --> 12:04.450
So from idle to running we'll use should move and from running to idle we'll use should move but using

12:04.450 --> 12:05.740
a not boolean.

12:06.580 --> 12:10.120
That way, we'll transition back if we should not move.

12:10.150 --> 12:17.550
And of course, that actually means that should move should be false if ground speed is less than three.

12:17.560 --> 12:17.920
Right.

12:17.920 --> 12:20.650
So we can actually change this to greater than.

12:23.710 --> 12:27.610
Should move should be true if speed is greater than three.

12:27.730 --> 12:34.870
And before we test this out, I'm going to go back into main states and go into idle and select the

12:34.870 --> 12:42.580
idle sequence player and make sure to check loop animation as we want that idle animation to be looping.

12:42.760 --> 12:44.260
Let's try this out.

12:46.200 --> 12:47.220
There we go.

12:47.940 --> 12:52.350
And we don't get that head jerk because now we're just going back to the idle state.

12:53.130 --> 12:56.590
And will only use the blend space if we're actually running.

12:56.610 --> 12:57.390
Perfect.

12:57.390 --> 12:57.840
All right.

12:57.840 --> 13:00.560
So now that we have movements, we have a game mode.

13:00.570 --> 13:06.870
We're almost done setting up the basics for this project, and then we'll move on to what we're really

13:06.870 --> 13:10.080
here for, which is the gameplay ability system.

13:10.080 --> 13:13.560
And that's where things are going to get really interesting.

13:13.560 --> 13:14.940
So great job.

13:14.940 --> 13:21.000
Just a couple more things to set up before we close out this section and move on to the interesting

13:21.000 --> 13:21.720
stuff.

13:21.900 --> 13:22.920
I'll see you soon.
