﻿1
00:00:04,380 --> 00:00:05,280
‫Hello and welcome.

2
00:00:05,290 --> 00:00:10,230
‫In this lecture, we're going to be making our very own scene component for the grabber, and we're

3
00:00:10,230 --> 00:00:16,830
‫going to print out its rotation so that we can see that it is indeed attached to the camera and the

4
00:00:16,830 --> 00:00:20,340
‫camera's rotation is affecting its rotation.

5
00:00:20,340 --> 00:00:22,250
‫Let's dive in and see how this works.

6
00:00:22,260 --> 00:00:28,530
‫Now, if you remember from seeing the demo, I would like to have a little statue in one of these cells

7
00:00:28,710 --> 00:00:37,560
‫and to allow us to pick it up and take it over to this alcove for placement.

8
00:00:37,890 --> 00:00:45,810
‫Now, the problem here is that I don't have that statue and I don't have a way of even knowing if I

9
00:00:45,810 --> 00:00:48,630
‫am pointing at it when I'm trying to pick it up.

10
00:00:48,870 --> 00:00:53,490
‫So that is what we're going to aim to try and solve in the next few lectures.

11
00:00:53,490 --> 00:00:58,290
‫So first of all, let's put a statue in place for us to use.

12
00:00:58,620 --> 00:01:01,980
‫So I'm going to open the cell door a little bit.

13
00:01:01,980 --> 00:01:08,580
‫So let's click on one of these cells and I'm going to go down to the door and I'm just going to rotate

14
00:01:08,580 --> 00:01:10,500
‫it nicely open so that we can get in.

15
00:01:11,040 --> 00:01:17,790
‫The next thing I'm going to do is it's very dark in here, so I'm going to put a new spotlight here.

16
00:01:18,090 --> 00:01:27,510
‫So let's go to the quickly add button, go to lights and find a spotlight and drag that in to our scene

17
00:01:27,510 --> 00:01:33,420
‫and drag it up the wall a little bit so that basically we are alerting the player to the fact that they're,

18
00:01:33,450 --> 00:01:38,610
‫hey, there's something of interest over in this corner that you might want to pay attention to.

19
00:01:38,610 --> 00:01:44,790
‫And we're going to go to the select the medieval dungeon folder and search for statue.

20
00:01:44,790 --> 00:01:49,680
‫And you can see we've got a golden one and we've got a stone one.

21
00:01:49,680 --> 00:01:57,270
‫I'm going to go for actually probably the gargoyle here and I need to give it some sort of something

22
00:01:57,270 --> 00:02:01,500
‫at the bottom, because I know that this mesh has has a hole in its bottom.

23
00:02:01,500 --> 00:02:08,820
‫So if we go and turn it upside down, it's going to look awful because it doesn't actually have a back

24
00:02:08,820 --> 00:02:09,540
‫side.

25
00:02:09,540 --> 00:02:16,590
‫So what I'm going to do is I'm going to take this gargoyle and I'm going to turn it well, I'm going

26
00:02:16,590 --> 00:02:18,480
‫to actually add a mesh underneath it.

27
00:02:18,480 --> 00:02:22,500
‫So we're going to look for some dirt mesh.

28
00:02:22,500 --> 00:02:28,380
‫And you can see I've got a little bit of dirt here that I'm going to just take and slap on to the existing

29
00:02:28,380 --> 00:02:30,000
‫gargoyle statue actor.

30
00:02:30,000 --> 00:02:34,560
‫So this dirt mound and you can see it's absolutely huge in comparison, but don't worry, we can fix

31
00:02:34,560 --> 00:02:36,090
‫that with a little bit of scale tool.

32
00:02:36,090 --> 00:02:42,270
‫So this dirt mound, so I'm going to go ahead and scale this locked in the details pane.

33
00:02:42,270 --> 00:02:45,750
‫Perhaps I'll start with 0.1 and see how small that is.

34
00:02:45,750 --> 00:02:52,470
‫And let's actually rotate the entire gargoyle actor so that we can see properly what we're doing.

35
00:02:52,500 --> 00:02:53,850
‫So have a look at that dirt mound.

36
00:02:53,850 --> 00:02:57,390
‫The dirt mound needs rotating by 180 degrees.

37
00:02:57,390 --> 00:03:02,250
‫And then let's use the scale tool to make it a little bit bigger.

38
00:03:02,280 --> 00:03:07,920
‫I'm just gonna finesse these figures a little bit using the details pane now I'm squashing it right

39
00:03:07,920 --> 00:03:10,890
‫flat with the scale in the Z and finessed it.

40
00:03:10,980 --> 00:03:14,550
‫I think just enough that it looks like there's a bottom to that.

41
00:03:14,550 --> 00:03:22,200
‫And now we can put this gargoyle rotated 90 degrees again and try and place it somewhere in the corner

42
00:03:22,200 --> 00:03:23,970
‫under this spotlight.

43
00:03:23,970 --> 00:03:27,150
‫So that's the aim for us to get hold of this mesh.

44
00:03:27,150 --> 00:03:28,950
‫But how are we going to do it?

45
00:03:28,950 --> 00:03:35,490
‫We're going to need a special component in order to do this, and we could use an actor component,

46
00:03:35,490 --> 00:03:38,310
‫but in this case, it's actually going to make more sense to use a scene component.

47
00:03:38,310 --> 00:03:43,560
‫Let's see y let's go ahead and go to the root of our content folder, clear out the search and open

48
00:03:43,560 --> 00:03:48,630
‫up our BP player and let's open up the full blueprint editor.

49
00:03:49,050 --> 00:03:56,400
‫And what we want to do is essentially to have something that tracks around when we're moving our first

50
00:03:56,400 --> 00:03:57,690
‫person camera.

51
00:03:57,690 --> 00:04:07,710
‫So as I play in here, you can see that I am looking all around and my camera is also looking all around.

52
00:04:07,710 --> 00:04:11,700
‫So what I want is something that points in the same direction as my camera.

53
00:04:11,700 --> 00:04:21,090
‫So the logical thing is to attach a component to this camera which would allow it to automatically rotate

54
00:04:21,090 --> 00:04:27,420
‫with that first person camera and always be pointing, always having its forward vector pointing in

55
00:04:27,420 --> 00:04:29,400
‫the forward direction of the camera.

56
00:04:29,490 --> 00:04:34,980
‫So that's what we're going to do, and that is exactly where we need a scene component, a component

57
00:04:34,980 --> 00:04:42,480
‫that can attach to other scene components and has a transform, has a location, rotation and scale.

58
00:04:42,480 --> 00:04:46,770
‫So the way we're going to do this is we're going to go to the add button in the components.

59
00:04:46,770 --> 00:04:48,030
‫But we could do this another way.

60
00:04:48,030 --> 00:04:55,800
‫We could also go to our content drawer, go click on C++ classes folder and hit add and hit add new

61
00:04:55,800 --> 00:04:57,120
‫C++ class.

62
00:04:57,210 --> 00:05:02,340
‫And then what we can do is we can go and scroll down to where you see it says scene component.

63
00:05:02,340 --> 00:05:03,480
‫So we're going to make.

64
00:05:03,710 --> 00:05:06,380
‫You seem component rather than an active component.

65
00:05:06,830 --> 00:05:09,110
‫And we're going to go ahead and hit next.

66
00:05:09,140 --> 00:05:15,740
‫Now we're going to call this the grabber because it's a component that's going to be eventually responsible

67
00:05:15,740 --> 00:05:23,570
‫for figuring out what to grab and then grabbing hold of it so that when we move, the grabber takes

68
00:05:23,570 --> 00:05:24,640
‫it withers.

69
00:05:24,650 --> 00:05:30,170
‫So we're going to go ahead and create this class, which takes us over to Visual Studio code with a

70
00:05:30,170 --> 00:05:36,710
‫grabber and a grab a dot CP and you can see that it's created a U grabber again with this U prefix for

71
00:05:36,710 --> 00:05:41,490
‫components and it inherits from the you seen components.

72
00:05:41,510 --> 00:05:44,600
‫That's how we know it is a is a scene component.

73
00:05:44,600 --> 00:05:47,840
‫Again with that inheritance being the is a relationship.

74
00:05:48,080 --> 00:05:54,410
‫If we went over to the mover to H, you could see that the inheritance is actually from you act a component.

75
00:05:54,410 --> 00:05:58,700
‫So that is a a you act a component but otherwise it looks exactly the same.

76
00:05:58,700 --> 00:06:01,250
‫It's got a big in play, it's got a tick component.

77
00:06:01,430 --> 00:06:04,850
‫And that's because actually a scene component is an act, a component.

78
00:06:04,850 --> 00:06:07,880
‫It just adds some more functionality on top.

79
00:06:07,880 --> 00:06:16,160
‫So now that it's a scene component, we should be able to go over in to our editor, go to our BPE player,

80
00:06:16,580 --> 00:06:22,340
‫and from here go to add and look for the grabber and the grabber.

81
00:06:22,340 --> 00:06:29,120
‫Now you see, I had my first person camera selected, so automatically added the grabber as a child

82
00:06:29,120 --> 00:06:32,420
‫component of that first person camera.

83
00:06:32,420 --> 00:06:36,140
‫So I'd like to challenge you to print the grabber rotation.

84
00:06:36,140 --> 00:06:41,300
‫The way we're going to do this is to get the component rotation this time, not the actor's rotation,

85
00:06:41,300 --> 00:06:46,190
‫because the important thing is actually how this particular component is rotated because it's attached

86
00:06:46,190 --> 00:06:47,060
‫to the camera.

87
00:06:47,510 --> 00:06:53,000
‫We're going to convert it to a string using the two compact string function of the F rotator.

88
00:06:53,000 --> 00:06:59,540
‫This time, because we're not using an F vector for rotation, it does actually have a two compact string

89
00:06:59,540 --> 00:07:00,080
‫function.

90
00:07:00,080 --> 00:07:04,060
‫However, then we're going to print that out using the EWI log.

91
00:07:04,070 --> 00:07:10,970
‫Remember you put a star before a string for strange reasons and then we're going to compile it, test

92
00:07:10,970 --> 00:07:13,400
‫it out and see does it change the rotation?

93
00:07:13,400 --> 00:07:17,930
‫Does it move with the camera, pause the video and have a go.

94
00:07:21,100 --> 00:07:21,580
‫Okay.

95
00:07:21,580 --> 00:07:22,380
‫Welcome back.

96
00:07:22,390 --> 00:07:24,710
‫So we're going to be printing this out in tech.

97
00:07:24,730 --> 00:07:27,130
‫I didn't mention that, but hopefully you figured that out.

98
00:07:27,220 --> 00:07:34,840
‫And what we're going to do is, first of all, create an F rotator, which is going to store my rotation

99
00:07:35,410 --> 00:07:41,050
‫and then we're going to get component rotation, parentheses.

100
00:07:41,050 --> 00:07:49,210
‫And then from this, we need to get an F string, which is going to be the rotation string, which we're

101
00:07:49,210 --> 00:07:52,810
‫going to do by doing the mini rotation dot.

102
00:07:53,540 --> 00:07:58,870
‫To compact string parentheses.

103
00:07:58,880 --> 00:08:09,440
‫Now we're going to type you log and we're going to have the grabber rotation percent sx and then we're

104
00:08:09,440 --> 00:08:13,760
‫going to remember the star before our rotation string like.

105
00:08:13,760 --> 00:08:19,640
‫So now let's go ahead and compile this and it looks like that was successful, which is always nice

106
00:08:19,640 --> 00:08:20,210
‫to see.

107
00:08:20,360 --> 00:08:26,930
‫And then we're going to go ahead and hit play and have our output log docked in the layout so that I

108
00:08:26,930 --> 00:08:28,820
‫can see it at all times.

109
00:08:28,820 --> 00:08:36,200
‫You can see the rotation is indeed being printed out and as I move up you can see my pitch.

110
00:08:36,350 --> 00:08:38,360
‫The P is changing.

111
00:08:38,690 --> 00:08:46,370
‫As I turn from side to side, the yaw is changing, but at no point is it kind of tilting from side

112
00:08:46,370 --> 00:08:48,590
‫to side, which would be the role.

113
00:08:48,590 --> 00:08:53,690
‫So that's why in the compact representation, the role is always set to zero.

114
00:08:53,690 --> 00:08:56,630
‫So you can think of it as role pitch and you're like in an airplane.

115
00:08:56,720 --> 00:09:03,590
‫So it does look like this is updating correctly, as I would expect to with the camera and I'm very

116
00:09:03,590 --> 00:09:05,270
‫happy with that result.

117
00:09:05,300 --> 00:09:05,750
‫Great stuff.

118
00:09:05,750 --> 00:09:10,100
‫So we've seen how we can create our own scene components, how we can attach them to stuff, and how

119
00:09:10,100 --> 00:09:16,130
‫they have their own notion of rotation, location and scale.

120
00:09:16,130 --> 00:09:18,440
‫Let's see you in the next lecture.

