﻿1
00:00:04,140 --> 00:00:05,950
‫Hello and welcome back.

2
00:00:05,970 --> 00:00:09,100
‫In this video, we're going to talk about the game mode.

3
00:00:09,120 --> 00:00:14,520
‫We're going to use the game mode to set the default -- class for our game.

4
00:00:14,520 --> 00:00:21,120
‫And eventually we'd like to handle Death for the Pawns as well as functionality for starting and ending

5
00:00:21,120 --> 00:00:21,680
‫the game.

6
00:00:21,690 --> 00:00:24,270
‫So let's talk about the game mode class now.

7
00:00:24,270 --> 00:00:27,660
‫Unreal Engine has a class called a game mode.

8
00:00:27,690 --> 00:00:31,950
‫The A is there because of course this derives from the actor class.

9
00:00:31,950 --> 00:00:39,990
‫Now a game mode has a parent class called a game mode base, which is a little bit more basic than a

10
00:00:39,990 --> 00:00:40,830
‫game mode.

11
00:00:40,830 --> 00:00:45,420
‫Now in Unreal Engine, game modes are good for handling the rules of the game.

12
00:00:45,420 --> 00:00:49,770
‫This means they can handle things like the win condition for the game.

13
00:00:50,070 --> 00:00:56,730
‫Now a game mode is a little bit more specialized and has extra functionality that we don't really need

14
00:00:56,730 --> 00:00:58,320
‫for this game project.

15
00:00:58,710 --> 00:01:05,100
‫It has the concept of Match State, which is used in multiplayer matchmaking sessions.

16
00:01:05,100 --> 00:01:10,460
‫So for this reason we're going to use a game mode base and not a game mode.

17
00:01:10,470 --> 00:01:17,280
‫Now the process for creating a game mode class is the same as creating any other C++ class, which is

18
00:01:17,280 --> 00:01:21,030
‫why this will be your challenge for this video.

19
00:01:21,300 --> 00:01:24,900
‫Create a new class based on game mode base.

20
00:01:24,900 --> 00:01:30,960
‫We're choosing game mode base because we don't need that extra functionality in the game mode class.

21
00:01:30,960 --> 00:01:34,740
‫Now call it tune tanks, game mode or something similar.

22
00:01:34,800 --> 00:01:38,940
‫And once you've finished, create a blueprint based on this class.

23
00:01:38,970 --> 00:01:42,120
‫Now we have a pawns folder and an actor's folder.

24
00:01:42,150 --> 00:01:48,510
‫Go ahead and create a new game mode folder and place the new blueprint in the game mode folder.

25
00:01:48,540 --> 00:01:53,040
‫Go ahead and pause the video and create your new game mode class now.

26
00:01:55,980 --> 00:01:56,430
‫Okay.

27
00:01:56,430 --> 00:02:00,110
‫So I'm back here in the editor and I'm ready to create my game mode.

28
00:02:00,120 --> 00:02:07,500
‫So I'm going to right click and select new C++ class from within the tune tanks folder in C++ classes.

29
00:02:07,500 --> 00:02:14,220
‫And I'm going to scroll down and I see here that there's game mode base as an option.

30
00:02:14,220 --> 00:02:18,960
‫Now you'll see the pop up says the game mode base defines the game being played.

31
00:02:18,990 --> 00:02:25,290
‫It governs the game rules, scoring what actors are allowed to exist in this game type and who may enter

32
00:02:25,290 --> 00:02:25,950
‫the game.

33
00:02:25,950 --> 00:02:31,800
‫So we're going to be using the game mode to determine our game rules, which will dictate when we can

34
00:02:31,800 --> 00:02:33,360
‫win or lose the game.

35
00:02:33,360 --> 00:02:40,650
‫I'm going to click next and I'm going to call this game mode, tune tanks, game mode and click Create

36
00:02:40,650 --> 00:02:41,250
‫Class.

37
00:02:41,250 --> 00:02:43,590
‫Now here's my tune tanks game mode.

38
00:02:43,590 --> 00:02:49,770
‫I have a dot H and a dot CP and they look pretty empty and we're going to change that in the videos

39
00:02:49,770 --> 00:02:50,130
‫to come.

40
00:02:50,130 --> 00:02:55,590
‫But for now we have our C++ class and we're ready to create a blueprint based on this.

41
00:02:55,590 --> 00:03:00,900
‫So back here in the editor, I'm going to make my game mode folder here in the blueprints folder.

42
00:03:00,900 --> 00:03:05,340
‫So I'm going to make a new folder called Game Mode.

43
00:03:05,430 --> 00:03:10,530
‫And inside the game mode, I'm going to right click and make a new blueprint class.

44
00:03:10,680 --> 00:03:17,850
‫And here under all classes, I'm going to search for tune tanks and here's Tune Tanks, game mode clicking

45
00:03:17,850 --> 00:03:18,600
‫select.

46
00:03:18,600 --> 00:03:25,470
‫I now have my blueprint and I'm going to call this beep underscore tune tanks game mode.

47
00:03:25,740 --> 00:03:27,780
‫So now I have a game mode.

48
00:03:27,780 --> 00:03:33,840
‫So now that we have a game mode, let's go through the steps of setting this to be our game mode for

49
00:03:33,840 --> 00:03:34,620
‫this game.

50
00:03:34,620 --> 00:03:39,600
‫And we can do that by going into edit and project settings.

51
00:03:39,600 --> 00:03:48,090
‫And under project we see maps and modes and here under default modes we see default game mode and you'll

52
00:03:48,090 --> 00:03:51,360
‫see that it's set to the game mode base class.

53
00:03:51,540 --> 00:03:55,640
‫We can click this dropdown and see that BP tune tanks.

54
00:03:55,650 --> 00:04:02,250
‫Game mode is an option and we can select that now under selected game mode, we can expand this dropdown

55
00:04:02,250 --> 00:04:07,950
‫and you'll see that there are a number of properties on the game mode class that we can set.

56
00:04:07,980 --> 00:04:14,460
‫We can set them here, but what I'd rather do is set them in the game mode blueprint itself so we can

57
00:04:14,460 --> 00:04:15,420
‫close this.

58
00:04:15,420 --> 00:04:16,980
‫There's no option to save.

59
00:04:16,980 --> 00:04:19,200
‫It's already going to save this for us.

60
00:04:19,200 --> 00:04:25,110
‫So we'll close the project settings and open up BP tune tanks, game mode.

61
00:04:25,140 --> 00:04:32,580
‫And here in the details panel under classes, we see a number of default classes designated for the

62
00:04:32,580 --> 00:04:33,090
‫game.

63
00:04:33,090 --> 00:04:37,260
‫Now, the one I'm interested in right now is default -- class.

64
00:04:37,260 --> 00:04:42,090
‫Here we can choose the default pawn that will be possessed when we start the game.

65
00:04:42,090 --> 00:04:48,360
‫So if I click the dropdown, I can see that BP pawn tank is an option and I'm going to select that.

66
00:04:48,360 --> 00:04:52,410
‫So I'm going to compile and save this and close out of it.

67
00:04:52,410 --> 00:04:58,350
‫Now we've set this tank to be possessed using the auto possess player variable.

68
00:04:58,350 --> 00:05:03,870
‫And to remind you, I'm going to search for auto possess player and see that it's set to player zero

69
00:05:03,870 --> 00:05:05,280
‫for this tank.

70
00:05:05,280 --> 00:05:12,390
‫So that allowed us to possess this particular pawn without having our custom game mode set specifying

71
00:05:12,390 --> 00:05:13,320
‫the pawn class.

72
00:05:13,320 --> 00:05:17,310
‫So now that we have a game mode, we're going to remove this pawn from the world.

73
00:05:17,310 --> 00:05:19,920
‫So I'm going to hit delete and delete it.

74
00:05:19,920 --> 00:05:26,130
‫Now I'm going to zoom all the way over to this little thing right here and select it.

75
00:05:26,160 --> 00:05:29,040
‫You'll see that this is called a player start.

76
00:05:29,040 --> 00:05:31,500
‫You can see that here in the world out minor.

77
00:05:31,500 --> 00:05:37,440
‫Now, since we have our default pawn class set in our game mode, when the game starts, our pawn will

78
00:05:37,440 --> 00:05:39,840
‫be spawned right here at the player start.

79
00:05:39,870 --> 00:05:45,960
‫Now if you saw this earlier in the course and maybe decided to remove it, you can always get a new

80
00:05:45,960 --> 00:05:46,290
‫player.

81
00:05:46,290 --> 00:05:49,380
‫Start by looking over here to the left in the place.

82
00:05:49,380 --> 00:05:50,520
‫Actors Panel.

83
00:05:50,520 --> 00:05:56,040
‫You'll see that there are a number of classes we can drag into our world, including player start now.

84
00:05:56,040 --> 00:05:58,410
‫We only want a single player start.

85
00:05:58,410 --> 00:06:03,750
‫If we had multiple player starts then Unreal Engine will be forced to choose one of them at random.

86
00:06:03,750 --> 00:06:08,250
‫But we only have a single player for this game, so we're going to use one player start.

87
00:06:08,250 --> 00:06:14,130
‫So if I go ahead and hit play, we'll see that my pawn is spawn at the location of that player.

88
00:06:14,130 --> 00:06:15,270
‫Start now.

89
00:06:15,270 --> 00:06:21,630
‫I'm moving quite slowly because we're spawning this actor based on the default blueprint and my movement

90
00:06:21,630 --> 00:06:25,530
‫speed is set in the default blueprint to a low value.

91
00:06:25,530 --> 00:06:28,680
‫So what I'd like to do is change my movement speed.

92
00:06:28,680 --> 00:06:35,820
‫So I'm going to go into the Pawns folder and open BP pawn tank and select BP Pawn Tank self.

93
00:06:35,820 --> 00:06:44,430
‫And here under speed I can up this value to say 700 and I'm going to put the turn rate at 120.

94
00:06:45,270 --> 00:06:49,260
‫Now, if I hit play, I can move around quite a bit faster.

95
00:06:50,760 --> 00:06:54,930
‫I'm going to go ahead and save BP -- tank, close out of it.

96
00:06:54,930 --> 00:06:58,320
‫And now we have our game mode set for the game.

97
00:06:58,320 --> 00:07:05,250
‫So in this video, we created the game mode class for our game and we set this as the default game mode

98
00:07:05,250 --> 00:07:11,130
‫both in the project settings and in the world out eyeliner to make sure that our particular level is

99
00:07:11,130 --> 00:07:13,080
‫using the correct game mode.

100
00:07:13,080 --> 00:07:19,920
‫We also set the default pawn class in the game mode blueprint and we used a player start to spawn that

101
00:07:19,920 --> 00:07:25,500
‫default pawn rather than having upon already in the world and using auto possess player.

102
00:07:25,500 --> 00:07:31,260
‫In the next video we're going to add more things to the game mode so that we can start handling gameplay

103
00:07:31,260 --> 00:07:33,600
‫logic related to the rules of the game.

104
00:07:33,630 --> 00:07:35,010
‫I'll see you in the next video.

