﻿1
00:00:04,040 --> 00:00:05,520
‫Hey, welcome back.

2
00:00:05,540 --> 00:00:10,250
‫In this video, we're going to work on a widget for displaying the win lose condition.

3
00:00:10,250 --> 00:00:11,540
‫So let's jump right in.

4
00:00:11,540 --> 00:00:15,530
‫Now we have our widget, we start game widget.

5
00:00:15,530 --> 00:00:19,220
‫Let's open that and we'll see that we have this get ready text.

6
00:00:19,220 --> 00:00:23,210
‫And in the event graph, we're setting this in event tech.

7
00:00:23,210 --> 00:00:29,030
‫Now aside from all this stuff, what we have here in the designer tab is exactly what we need for the

8
00:00:29,030 --> 00:00:34,130
‫game over text so we can duplicate this blueprint and change a few things.

9
00:00:34,130 --> 00:00:41,030
‫I'm going to close out of it and here in the content browser I can right click on this WP Start Game

10
00:00:41,030 --> 00:00:43,250
‫Widget Blueprint and duplicate.

11
00:00:43,370 --> 00:00:46,490
‫Now we need to choose a new name for this widget.

12
00:00:46,490 --> 00:00:50,180
‫I'm going to call this end game widget instead of start game widget.

13
00:00:50,180 --> 00:00:54,410
‫So renaming this, we now have WPP End Game Widget.

14
00:00:54,410 --> 00:01:01,940
‫Let's go ahead and double click this and we have the same text, get ready and it's called display text

15
00:01:01,940 --> 00:01:04,220
‫and it's set to is variable.

16
00:01:04,220 --> 00:01:11,210
‫Now let's go into the graph tab and we don't need any of this blueprint logic so we can highlight everything

17
00:01:11,210 --> 00:01:12,290
‫and delete it.

18
00:01:12,290 --> 00:01:15,110
‫In fact, we can delete the countdown variable.

19
00:01:15,110 --> 00:01:19,520
‫You can always delete a variable by selecting it here and hitting the delete key.

20
00:01:19,520 --> 00:01:21,380
‫So let's leave the display text.

21
00:01:21,380 --> 00:01:23,930
‫We need that one and we can click compile.

22
00:01:23,930 --> 00:01:28,190
‫And now we need to figure out how to set the text for this widget.

23
00:01:28,220 --> 00:01:30,530
‫Now let's go to our game mode blueprint.

24
00:01:30,560 --> 00:01:32,960
‫Here we have event game over.

25
00:01:32,960 --> 00:01:36,470
‫This is where we can add the widget to the viewport.

26
00:01:36,470 --> 00:01:42,440
‫So I'm going to highlight these nodes, the print string and the bool to text conversion node and delete

27
00:01:42,440 --> 00:01:49,070
‫those and use a create widget node to add our new endgame widget to the viewport.

28
00:01:49,070 --> 00:01:54,830
‫So I'm going to drag off type create widget and get that create widget node.

29
00:01:54,830 --> 00:01:58,970
‫Now for the class, I'm going to select end game widget.

30
00:01:58,970 --> 00:02:05,000
‫So we have WPP end game widget and the next thing to do is add it to the viewport.

31
00:02:05,000 --> 00:02:11,360
‫So I'm going to click and drag off of the output execution pin and type add to viewport.

32
00:02:11,360 --> 00:02:17,120
‫And now I can't forget that I need to take the return value from create widget and plug it into the

33
00:02:17,120 --> 00:02:19,130
‫target for add to viewport.

34
00:02:19,130 --> 00:02:25,310
‫So now as soon as our game over blueprint implementable event gets called, we will be adding this widget

35
00:02:25,310 --> 00:02:26,420
‫to the viewport.

36
00:02:26,420 --> 00:02:33,200
‫Now the last thing to do is to set its text based on whether or not we've won the game, which we know

37
00:02:33,200 --> 00:02:37,040
‫because we have this boolean from our event game over.

38
00:02:37,040 --> 00:02:41,240
‫So we need to think about what to do once we've won the game.

39
00:02:41,240 --> 00:02:46,970
‫Now we know that we can use a set text node to set the text of a particular widget.

40
00:02:46,970 --> 00:02:53,690
‫In our widget blueprint, we need to be able to access that text widget, which we called display text.

41
00:02:53,690 --> 00:03:01,370
‫So what we can do is from our Create Widget blueprint, the return value, which returns a WPP end game

42
00:03:01,370 --> 00:03:06,500
‫widget object reference can be used to access variables in that widget.

43
00:03:06,500 --> 00:03:13,310
‫So let's click from the return value and drag off and type display text and we'll see that we can get

44
00:03:13,310 --> 00:03:15,290
‫display text from there.

45
00:03:15,290 --> 00:03:17,090
‫We can use a set text to Node.

46
00:03:17,090 --> 00:03:24,710
‫So let's click the output from display text, drag off and release and type set text and we can see

47
00:03:24,710 --> 00:03:28,760
‫that set text, parentheses, text is an option here.

48
00:03:28,760 --> 00:03:34,460
‫Now just to test this out, just after we've added the end game widget to the viewport, we can hook

49
00:03:34,460 --> 00:03:40,760
‫up the execution pin to a set text node where we can set the display text text value.

50
00:03:40,760 --> 00:03:47,000
‫So for now, I'm just going to type game over and now with a compile, I'm going to play test this and

51
00:03:47,000 --> 00:03:50,420
‫see if we can get that widget showing up on the screen.

52
00:03:50,420 --> 00:03:55,700
‫So I'll go ahead and let these turrets kill me and now I see game over.

53
00:03:55,700 --> 00:03:57,890
‫But for me that's not quite enough.

54
00:03:57,890 --> 00:04:01,010
‫I'd like to see if I've won or lost the game.

55
00:04:01,010 --> 00:04:07,070
‫Now there are various ways to do this, and you may even think that you have an idea in mind regarding

56
00:04:07,070 --> 00:04:09,710
‫how to set this text value.

57
00:04:09,710 --> 00:04:15,050
‫In fact, you might even wish to pause the video and see if you can implement this yourself.

58
00:04:15,050 --> 00:04:19,850
‫So if you feel like the challenge, go ahead and pause the video now and see if you can figure this

59
00:04:19,850 --> 00:04:20,300
‫out.

60
00:04:23,330 --> 00:04:23,720
‫Okay.

61
00:04:23,720 --> 00:04:26,330
‫So if you figure this out, congratulations.

62
00:04:26,330 --> 00:04:29,180
‫You have implemented the game over widget.

63
00:04:29,210 --> 00:04:33,050
‫Now I'm going to show you a special node that I'm going to use.

64
00:04:33,050 --> 00:04:38,400
‫And you may not have seen this before, but this node is called a select node.

65
00:04:38,420 --> 00:04:41,150
‫I'm going to right click and type select.

66
00:04:41,150 --> 00:04:46,430
‫And if I select, select, I have this node that takes an index.

67
00:04:46,430 --> 00:04:53,450
‫The index is a value which will determine what gets selected and returned as the return value.

68
00:04:53,450 --> 00:05:00,920
‫And I can click the dropdown and select boolean and for the return value I can right click on it and

69
00:05:00,920 --> 00:05:02,720
‫select change pin type.

70
00:05:02,720 --> 00:05:08,840
‫And then I get this dropdown that says Wild Card and I can change this to a different type of output

71
00:05:08,840 --> 00:05:10,220
‫value such as text.

72
00:05:10,220 --> 00:05:18,560
‫So I'm going to select text and now I have this select node that has a true and a false input as well

73
00:05:18,560 --> 00:05:20,360
‫as the index, which is a boolean.

74
00:05:20,360 --> 00:05:24,680
‫And the true false and return values are text values.

75
00:05:24,680 --> 00:05:27,080
‫They have the text data type.

76
00:05:27,380 --> 00:05:35,300
‫Now the way the select node works is we have an index and we selected Boolean as the type for this input,

77
00:05:35,300 --> 00:05:42,710
‫which means we can plug in a boolean value and the return value will be different depending on the value

78
00:05:42,710 --> 00:05:43,640
‫of the index.

79
00:05:43,640 --> 00:05:51,650
‫If the value of the boolean is true, then we will return a text value depending on the true input for

80
00:05:51,650 --> 00:05:52,820
‫the select node.

81
00:05:52,820 --> 00:05:57,050
‫And if it's false, we'll get the value assigned to the false input.

82
00:05:57,080 --> 00:06:03,410
‫Now these are input pins for true and false, so we can plug in text values to them directly, or we

83
00:06:03,410 --> 00:06:05,750
‫could hard code them in the text boxes.

84
00:06:05,750 --> 00:06:11,480
‫For example, we can type in text you lost for false and you won for true.

85
00:06:11,480 --> 00:06:16,550
‫And what we get returned from this select node depends on that input index.

86
00:06:16,550 --> 00:06:20,000
‫If it's true, then the return value will be u one.

87
00:06:20,000 --> 00:06:23,060
‫And if it's false, we will get you lost.

88
00:06:23,090 --> 00:06:29,060
‫So if you haven't implemented the solution already, I'd like you to try using the select node to do

89
00:06:29,060 --> 00:06:29,570
‫so.

90
00:06:29,570 --> 00:06:33,440
‫So use a select node and set the false text to you.

91
00:06:33,440 --> 00:06:34,080
‫Lost.

92
00:06:34,100 --> 00:06:41,600
‫Set the true text to you one and hook up the player one boolean which we get from our game over event

93
00:06:41,600 --> 00:06:43,520
‫resulting from our blueprint.

94
00:06:43,520 --> 00:06:45,680
‫Implementable Event Game over.

95
00:06:45,710 --> 00:06:53,450
‫Once you've done this use set text to set the widget text, pause the video and implement this now.

96
00:06:56,900 --> 00:06:57,230
‫Okay.

97
00:06:57,230 --> 00:07:03,980
‫So I have my select and I need to hook up the index which is a boolean and I'm going to use one game

98
00:07:03,980 --> 00:07:05,870
‫from the event game over.

99
00:07:06,080 --> 00:07:12,530
‫Now based on this input boolean, I'll get a different return value depending on whether the index is

100
00:07:12,530 --> 00:07:13,500
‫true or false.

101
00:07:13,520 --> 00:07:19,160
‫If it's true, I'd like to print you one with three exclamation points.

102
00:07:19,160 --> 00:07:24,530
‫And if it's false, I'd like to print out you lost with a single exclamation point.

103
00:07:24,650 --> 00:07:26,120
‫Now the return value.

104
00:07:26,150 --> 00:07:28,760
‫I'm going to hook up to the set text node.

105
00:07:28,760 --> 00:07:33,970
‫And now we should see you lost or you won, depending on whether we've lost or won the game.

106
00:07:33,980 --> 00:07:39,260
‫So with a compile, I'm going to hit play and I'm first going to try to win the game.

107
00:07:39,260 --> 00:07:41,450
‫So I'm going to try really hard not to lose.

108
00:07:41,480 --> 00:07:43,220
‫There's the first second.

109
00:07:43,250 --> 00:07:43,850
‫There we go.

110
00:07:43,850 --> 00:07:45,230
‫And I see I won.

111
00:07:45,680 --> 00:07:50,570
‫Now I can go ahead and try the lose condition, which should be pretty easy.

112
00:07:50,570 --> 00:07:52,370
‫I just have to get shot twice.

113
00:07:53,040 --> 00:07:54,030
‫There's one.

114
00:07:55,070 --> 00:07:56,180
‫And there's two.

115
00:07:56,180 --> 00:08:00,680
‫And you'll see that my tank disappears and I've lost the game.

116
00:08:00,890 --> 00:08:01,790
‫Perfect.

117
00:08:02,150 --> 00:08:05,960
‫So this takes care of the winning and losing conditions.

118
00:08:06,290 --> 00:08:13,250
‫So in summary, we have displayed the game over status to the player and we're showing that in the form

119
00:08:13,250 --> 00:08:14,520
‫of a text widget.

120
00:08:14,540 --> 00:08:19,670
‫We now have a functional game, so this is a huge milestone.

121
00:08:19,700 --> 00:08:22,310
‫The only thing left is the special effects.

122
00:08:22,310 --> 00:08:27,350
‫We need some sound effects and we need some explosion effects and some weapon trails and things like

123
00:08:27,350 --> 00:08:27,800
‫that.

124
00:08:27,800 --> 00:08:33,650
‫So we're going to wrap up this game by adding those effects and polishing the overall game in the videos

125
00:08:33,650 --> 00:08:34,120
‫to come.

126
00:08:34,130 --> 00:08:36,440
‫So we're almost done with this section.

127
00:08:36,470 --> 00:08:39,620
‫Great job and I'll see you in the next video.

