﻿1
00:00:04,220 --> 00:00:05,000
‫Hello and welcome.

2
00:00:05,000 --> 00:00:09,770
‫In this lecture, we are going to be getting a third person camera set up like so.

3
00:00:09,770 --> 00:00:18,110
‫So when we back into a wall, it is going to keep our character in view and not disappear within the

4
00:00:18,110 --> 00:00:18,290
‫wall.

5
00:00:18,290 --> 00:00:20,900
‫Let's dive in and see how this can be achieved in Unreal.

6
00:00:21,860 --> 00:00:22,770
‫All righty, then.

7
00:00:22,790 --> 00:00:24,590
‫A third person camera.

8
00:00:24,590 --> 00:00:25,250
‫How are we going to do this?

9
00:00:25,250 --> 00:00:29,360
‫Let's go and do this in Blueprint, because there's really no point doing this in C++.

10
00:00:29,360 --> 00:00:30,890
‫It's all configuration.

11
00:00:30,890 --> 00:00:33,980
‫It's really much easier to do with scene components in Blueprint.

12
00:00:33,980 --> 00:00:38,990
‫So let's go to the BP shooter character, open the full blueprint editor so we can see the viewport,

13
00:00:38,990 --> 00:00:41,750
‫so we can see all of the components over on the left.

14
00:00:41,840 --> 00:00:48,020
‫And what we're going to do is add in a little bit of a camera component.

15
00:00:48,020 --> 00:00:50,000
‫So go to add components camera.

16
00:00:50,000 --> 00:00:57,110
‫And the easiest way to get a third person view is and something you probably already knew, just move

17
00:00:57,110 --> 00:01:02,030
‫this camera out and over the right shoulder or left shoulder, whichever way you want to move it back

18
00:01:02,030 --> 00:01:04,010
‫and you can go ahead and have a play.

19
00:01:04,010 --> 00:01:09,770
‫And that's going to be a third person view, simple as, but things are not going to be that simple.

20
00:01:09,770 --> 00:01:10,490
‫For a start.

21
00:01:10,490 --> 00:01:14,240
‫You can see that our control rotation isn't entirely working.

22
00:01:14,240 --> 00:01:15,350
‫It can't go up and down.

23
00:01:15,720 --> 00:01:19,820
‫And but also if I back into a wall, you can see that I'm looking through the wall.

24
00:01:19,820 --> 00:01:20,810
‫That's no good, is it?

25
00:01:20,810 --> 00:01:25,520
‫So let's try and see if we can make this a little bit better.

26
00:01:26,390 --> 00:01:34,550
‫Now, Unreal has a component for this that makes using cameras in this way a lot, a lot better.

27
00:01:34,550 --> 00:01:42,020
‫But before we do that, I want us to go to the camera component and fix that rotation problem so you

28
00:01:42,020 --> 00:01:46,910
‫can go to the camera options and check the pawn use control rotation.

29
00:01:46,910 --> 00:01:51,020
‫And what that's going to do is it's going to rotate the camera using the control rotation.

30
00:01:51,020 --> 00:01:53,300
‫Let's go ahead and hit play and see if that works.

31
00:01:53,300 --> 00:01:57,140
‫Yes, it does rotate, but unfortunately it rotates around the camera.

32
00:01:57,140 --> 00:01:59,030
‫That's not a very third person.

33
00:01:59,150 --> 00:02:05,360
‫Look, you tend to expect it to rotate around that kind of point over the shoulder here so that you

34
00:02:05,360 --> 00:02:08,240
‫can always keep that character within view.

35
00:02:08,570 --> 00:02:08,890
‫Okay.

36
00:02:08,930 --> 00:02:12,620
‫In enough teasing, what we want here is the spring arm component.

37
00:02:12,620 --> 00:02:17,210
‫I'm going to select the capsule component, go to add component because I want this to be a child of

38
00:02:17,210 --> 00:02:17,930
‫the camera component.

39
00:02:17,930 --> 00:02:19,880
‫Add a spring arm in here.

40
00:02:20,240 --> 00:02:26,390
‫For some reason, Unreal is focused on trying to put these components in my character's crotch.

41
00:02:26,510 --> 00:02:31,010
‫Now let's go to the camera and make the camera a child of the spring arm.

42
00:02:31,010 --> 00:02:37,190
‫And I'm going to just reset its location and transform location under the details pane so that when

43
00:02:37,190 --> 00:02:41,660
‫we select the spring arm, you can see that the camera goes on the end of the spring arm.

44
00:02:41,810 --> 00:02:46,490
‫And then what I'm going to do is you could move the camera, but I'll show you why in a second.

45
00:02:46,490 --> 00:02:47,600
‫That's not a good idea.

46
00:02:47,600 --> 00:02:49,760
‫We're going to move the spring arm instead.

47
00:02:49,760 --> 00:02:53,240
‫And because the camera is ID to the spring arm, it's moving with it.

48
00:02:53,440 --> 00:02:55,310
‫We're going to move that to.

49
00:02:55,340 --> 00:03:02,090
‫So there's this point just to the right of my character's mesh, the right of his shoulder, and that's

50
00:03:02,090 --> 00:03:03,980
‫what the camera is going to try and look at.

51
00:03:03,980 --> 00:03:10,040
‫So if we go ahead and hit play now and move, the movement is still not quite right.

52
00:03:10,040 --> 00:03:14,930
‫But we should have fewer problems with the walls.

53
00:03:14,930 --> 00:03:18,680
‫You can see that now I can back into a wall and my camera doesn't go through the wall.

54
00:03:18,680 --> 00:03:22,640
‫That is the functioning of the spring arm itself.

55
00:03:22,970 --> 00:03:29,930
‫So, you know, when I went into camera and I set the use -- control rotation checked that we actually

56
00:03:29,930 --> 00:03:34,460
‫want to uncheck because it's not the camera that we want to rotate, but rather the spring arm.

57
00:03:34,460 --> 00:03:39,320
‫Because you can see that if I use my rotation widget, which I'm going to use E to switch over to my

58
00:03:39,320 --> 00:03:45,560
‫rotation widget, if I were to rotate the spring arm, you can see that I'd get the right sort of rotation.

59
00:03:45,560 --> 00:03:49,640
‫It wouldn't be just the camera looking up and down, because if I select the camera and rotate that,

60
00:03:49,640 --> 00:03:52,460
‫you can see the camera is just looking up and down, which is the behavior we were seeing.

61
00:03:52,460 --> 00:03:55,190
‫We want it pivoting around that spring arm.

62
00:03:55,280 --> 00:04:00,950
‫So what we can do is we can select the spring arm and go to use pawn control rotation on the spring

63
00:04:00,950 --> 00:04:01,940
‫arm itself.

64
00:04:01,940 --> 00:04:07,190
‫Now, if we hit play and we move around, you can see, yes, that is much more like it.

65
00:04:07,190 --> 00:04:11,390
‫That is third person camera at its finest.

66
00:04:11,390 --> 00:04:16,880
‫And you can see that we're able to move into walls and that is no problem whatsoever.

67
00:04:17,210 --> 00:04:23,450
‫So like to run a little experiment as part of your learning here, we're going to try and figure out

68
00:04:23,450 --> 00:04:24,950
‫why not move the camera?

69
00:04:24,950 --> 00:04:28,190
‫Why did we move the spring arm and not the camera to get a third person view?

70
00:04:28,430 --> 00:04:32,900
‫So try moving the camera and not the spring arm and see what happens.

71
00:04:32,900 --> 00:04:35,750
‫See if you can figure out why I did that.

72
00:04:36,170 --> 00:04:37,220
‫Pause the video and have a go.

73
00:04:38,540 --> 00:04:38,780
‫Okay.

74
00:04:38,780 --> 00:04:39,370
‫Welcome back.

75
00:04:39,380 --> 00:04:41,030
‫So let's give this a shot.

76
00:04:41,090 --> 00:04:41,990
‫I have.

77
00:04:41,990 --> 00:04:47,510
‫I'm going to just go ahead and put our spring arm back in its original location just by resetting it

78
00:04:47,510 --> 00:04:56,300
‫and taking the camera instead using the movement widget and bringing that up into a higher location

79
00:04:56,720 --> 00:04:58,970
‫over up and to the left.

80
00:04:59,090 --> 00:05:04,010
‫So the spring arm, you can see the little red line is pointing back here.

81
00:05:04,050 --> 00:05:08,690
‫The camera is up there and to the left go ahead and hit play in this configuration.

82
00:05:08,690 --> 00:05:09,710
‫Let's see if we can figure out.

83
00:05:09,710 --> 00:05:12,770
‫Well, seems to be mostly working the same, doesn't it?

84
00:05:12,770 --> 00:05:14,360
‫Let's go and have a look.

85
00:05:14,450 --> 00:05:16,640
‫Go near an edge of something.

86
00:05:17,430 --> 00:05:20,490
‫And see if we can figure out what's going wrong.

87
00:05:20,520 --> 00:05:21,300
‫There you go.

88
00:05:21,300 --> 00:05:25,640
‫That is exactly an example of why we move the spring on.

89
00:05:25,680 --> 00:05:32,010
‫Now, what's going on here is that that little red line of the spring arm, this one here that was in

90
00:05:32,010 --> 00:05:36,480
‫the clear when we went through this doorway, it was kind of going through here.

91
00:05:36,480 --> 00:05:38,580
‫So it was going through the hallway just fine.

92
00:05:38,610 --> 00:05:40,580
‫The red line was clear.

93
00:05:40,590 --> 00:05:42,060
‫The camera wasn't clear.

94
00:05:42,060 --> 00:05:45,300
‫The camera was up somewhere inside the wall.

95
00:05:45,600 --> 00:05:50,880
‫So what we want to have happen is that this red line needs to be wherever.

96
00:05:50,880 --> 00:05:53,160
‫We need to clear the view for the camera.

97
00:05:53,160 --> 00:05:57,540
‫And that's why we want the camera to always be looking down the red line.

98
00:05:57,540 --> 00:06:03,360
‫So if we reset it and go and have a look at our spring arm, you can see that now the red line is kind

99
00:06:03,360 --> 00:06:09,360
‫of pointing, firing out of the camera to the point of interest, which, as we said, Unreal has got

100
00:06:09,360 --> 00:06:11,550
‫a bit of a interesting point of interest.

101
00:06:11,550 --> 00:06:15,450
‫And in this case, it should be just above the shoulder like this.

102
00:06:16,110 --> 00:06:21,880
‫And that's the point that we're going to want to go and get the camera to focus in on as much as possible.

103
00:06:21,900 --> 00:06:28,050
‫Now, this does have an interesting point, which is that we want to if we wanted to say rotate this

104
00:06:28,050 --> 00:06:32,520
‫spring arm, you can't simply just go ahead and rotate the spring arm.

105
00:06:32,520 --> 00:06:33,330
‫That doesn't work.

106
00:06:33,330 --> 00:06:35,510
‫It seems to want to go straight out backwards.

107
00:06:35,520 --> 00:06:38,700
‫And the reason for this is it's in the settings of the spring arm itself.

108
00:06:38,700 --> 00:06:44,130
‫You can see that there is this socket offset, target offset and the spring arm length.

109
00:06:44,130 --> 00:06:47,460
‫So the length is telling us how long that length is.

110
00:06:47,460 --> 00:06:48,750
‫That's kind of makes sense.

111
00:06:48,930 --> 00:06:54,690
‫But if you want to do a rotation type of thing, then you can use the offsets.

112
00:06:54,690 --> 00:07:01,200
‫There's no real kind of rotation going on here, but rather we're just kind of moving that camera over,

113
00:07:01,200 --> 00:07:02,850
‫using the offsets.

114
00:07:02,850 --> 00:07:07,190
‫And then if you wanted to rotate the camera tool, you could rotate the camera independently so that

115
00:07:07,200 --> 00:07:13,320
‫if it was pointing more in towards the player like so and because we've still got that red line set

116
00:07:13,320 --> 00:07:15,780
‫up in the right way, the camera is going to work.

117
00:07:15,780 --> 00:07:22,490
‫It's going to keep visibility clear towards the player as much as is physically possible.

118
00:07:22,500 --> 00:07:25,410
‫Now, I'm just going to go ahead and tweak this more to my liking.

119
00:07:25,410 --> 00:07:31,350
‫So I'm going to move it a little bit closer to the shoulder here, because if I got the camera coming

120
00:07:31,350 --> 00:07:35,280
‫in, I want it to almost be looking down the barrel of the gun.

121
00:07:36,030 --> 00:07:38,850
‫But then I don't want any rotation on the camera itself.

122
00:07:38,850 --> 00:07:45,150
‫I find that it's not really necessary, but I do want to have a bit of a spring arm offset so that we

123
00:07:45,150 --> 00:07:53,640
‫can get that camera looking over slightly more to the right when we are not near a wall.

124
00:07:53,640 --> 00:07:58,290
‫And as we get near a wall, it's going to look closer and closer to the player's shoulder.

125
00:07:58,290 --> 00:07:59,070
‫Let's play that.

126
00:07:59,090 --> 00:08:00,030
‫See how that feels.

127
00:08:00,030 --> 00:08:03,720
‫So that's looking like I'm a bit too far over to the right here.

128
00:08:03,720 --> 00:08:05,160
‫Let's bring it in again.

129
00:08:05,640 --> 00:08:11,460
‫I think about maybe 60 units would be good like so just to have a nice round number, I'm going to hit

130
00:08:11,460 --> 00:08:17,220
‫play and you can see that's kind of in the right sort of spot for a third person view in my opinion.

131
00:08:17,220 --> 00:08:23,310
‫And if I go up against a wall, you can see it kind of brings me closer into the shoulder so I can still

132
00:08:23,310 --> 00:08:24,480
‫keep an eye on my character.

133
00:08:24,480 --> 00:08:26,100
‫I'm probably going to have a gun barrel.

134
00:08:26,100 --> 00:08:29,730
‫This might need some more tweaking later on when we've got our animations in place and we actually want

135
00:08:29,730 --> 00:08:33,450
‫to be looking down the gun barrel when we zoom in, that's fine.

136
00:08:33,450 --> 00:08:35,760
‫We don't need to do that just yet.

137
00:08:37,190 --> 00:08:42,200
‫So hopefully you have got now a working knowledge of the spring arm and camera and how we can use those

138
00:08:42,200 --> 00:08:46,250
‫two components together to create a third person camera.

139
00:08:46,310 --> 00:08:49,490
‫Now, all of that brings out the fact that our animations are not there.

140
00:08:49,490 --> 00:08:51,470
‫He's just standing in a static a pose.

141
00:08:51,470 --> 00:08:55,520
‫So in the next lecture, we're going to look at adding in those skeletal animations.

142
00:08:55,520 --> 00:08:56,210
‫So you there.

