WEBVTT

1
00:00:05.740 --> 00:00:07.410 A:middle L:90%
Hey there, welcome back to the third person camera

2
00:00:07.410 --> 00:00:09.500 A:middle L:90%
tutorials and Unity in this lesson we're gonna be

3
00:00:09.500 --> 00:00:11.570 A:middle L:90%
working on getting our pivots to be a little bit

4
00:00:11.570 --> 00:00:14.189 A:middle L:90%
more accurate right now, if you look at them,

5
00:00:14.199 --> 00:00:16.129 A:middle L:90%
you can see in the angle value, if

6
00:00:16.129 --> 00:00:19.329 A:middle L:90%
I slam exactly backwards on the stick, I end

7
00:00:19.329 --> 00:00:22.859 A:middle L:90%
up getting angles around uh usually like 160 or

8
00:00:22.870 --> 00:00:25.320 A:middle L:90%
or lower, they're not that accurate. Uh and

9
00:00:25.320 --> 00:00:27.390 A:middle L:90%
the reason for this is because each one of these

10
00:00:27.390 --> 00:00:30.890 A:middle L:90%
animations has a certain condition the gets met and during

11
00:00:30.890 --> 00:00:34.740 A:middle L:90%
that condition it executes a transition period and that transition

12
00:00:34.740 --> 00:00:37.130 A:middle L:90%
period can be anywhere from half a second to a

13
00:00:37.130 --> 00:00:39.039 A:middle L:90%
full second however long you want. So if I

14
00:00:39.039 --> 00:00:40.909 A:middle L:90%
make these transitions a little bit longer, you'll be

15
00:00:40.909 --> 00:00:43.460 A:middle L:90%
able to see that that accuracy goes down even further.

16
00:00:44.640 --> 00:00:48.350 A:middle L:90%
There's 139 and that's because uh the angle values

17
00:00:48.350 --> 00:00:50.729 A:middle L:90%
still being set during this transition period and the character

18
00:00:50.729 --> 00:00:52.829 A:middle L:90%
is moving during that. So it's it's giving us

19
00:00:52.829 --> 00:00:54.969 A:middle L:90%
really inaccurate angle values, so we're gonna learn how

20
00:00:54.969 --> 00:00:56.340 A:middle L:90%
to change that and get it to be a little

21
00:00:56.340 --> 00:00:57.899 A:middle L:90%
bit better. So first of all, I would

22
00:00:57.899 --> 00:01:00.420 A:middle L:90%
just make these not quite as large because they don't,

23
00:01:00.429 --> 00:01:02.090 A:middle L:90%
they don't need to be that big transitions.

24
00:01:02.100 --> 00:01:04.269 A:middle L:90%
Um that's one thing you can do, but the

25
00:01:04.269 --> 00:01:07.659 A:middle L:90%
better thing to do is definitely to uh to spend

26
00:01:07.659 --> 00:01:10.760 A:middle L:90%
some time working on your, on your logic,

27
00:01:11.340 --> 00:01:15.010 A:middle L:90%
if you look at Mario when he runs and if

28
00:01:15.010 --> 00:01:17.409 A:middle L:90%
you slam back exactly on the stick, it makes

29
00:01:17.409 --> 00:01:19.730 A:middle L:90%
a perfect 180 degree turn and this is what the

30
00:01:19.730 --> 00:01:21.829 A:middle L:90%
user expects. So that's what your game should provide

31
00:01:21.829 --> 00:01:23.099 A:middle L:90%
for them. It's the same sort of thing here

32
00:01:23.099 --> 00:01:27.370 A:middle L:90%
in Zelda, if you run and then change direction

33
00:01:27.370 --> 00:01:30.260 A:middle L:90%
abruptly, it's hard to get it to work,

34
00:01:30.260 --> 00:01:33.680 A:middle L:90%
but there is pivoting in this game to there you

35
00:01:33.680 --> 00:01:36.459 A:middle L:90%
go. So it's it's exactly 180 as well.

36
00:01:36.939 --> 00:01:38.299 A:middle L:90%
So we need to get ours to be a bit

37
00:01:38.299 --> 00:01:40.859 A:middle L:90%
more accurate. Then the way we're going to do

38
00:01:40.859 --> 00:01:42.459 A:middle L:90%
this is we need to recognize when these transitions are

39
00:01:42.459 --> 00:01:47.510 A:middle L:90%
happening and make our code react to that and consider

40
00:01:47.510 --> 00:01:49.989 A:middle L:90%
that during a pivot. So it's kind of

41
00:01:49.989 --> 00:01:51.469 A:middle L:90%
unintuitive the way this works and there's not a lot

42
00:01:51.469 --> 00:01:53.730 A:middle L:90%
of documentation on it. But if you look at

43
00:01:53.730 --> 00:01:57.370 A:middle L:90%
the animator controller, it has a method called get

44
00:01:57.379 --> 00:02:01.099 A:middle L:90%
animator transition info and that gives you a animator transition

45
00:02:01.099 --> 00:02:06.189 A:middle L:90%
infrastruct. And what this does is we can access

46
00:02:06.189 --> 00:02:08.189 A:middle L:90%
it just in the same way that we did with

47
00:02:08.330 --> 00:02:14.289 A:middle L:90%
with our with our state info object here. So

48
00:02:14.289 --> 00:02:15.949 A:middle L:90%
we just want to make another one of these info

49
00:02:15.949 --> 00:02:17.370 A:middle L:90%
objects and just query that in the same way that

50
00:02:17.370 --> 00:02:22.349 A:middle L:90%
we're querying it for these pivot IDs, we want

51
00:02:22.349 --> 00:02:24.159 A:middle L:90%
to make another id for each one of these transitions

52
00:02:24.539 --> 00:02:28.009 A:middle L:90%
and it may not be exactly obvious what the name

53
00:02:28.009 --> 00:02:30.159 A:middle L:90%
of the transition is. It's not this year,

54
00:02:30.159 --> 00:02:32.189 A:middle L:90%
it's base layer dot locomotion to base layer dot locomotion

55
00:02:32.189 --> 00:02:37.099 A:middle L:90%
pivot are there is no space between these two characters

56
00:02:37.099 --> 00:02:39.389 A:middle L:90%
here, but there is a space between uh the

57
00:02:39.400 --> 00:02:43.960 A:middle L:90%
word and the arrow on either side. So took

58
00:02:43.960 --> 00:02:45.129 A:middle L:90%
me a while to figure that out. And there's

59
00:02:45.129 --> 00:02:47.030 A:middle L:90%
not a lot of people online who who have much

60
00:02:47.039 --> 00:02:50.409 A:middle L:90%
to say about that. So hopefully this is something

61
00:02:50.419 --> 00:02:53.599 A:middle L:90%
unique, this tutorial provide. So we want to

62
00:02:53.599 --> 00:02:54.659 A:middle L:90%
change that. You want to make two new variables?

63
00:02:58.240 --> 00:03:01.800 A:middle L:90%
Yeah, we're going to make one called locomotion

64
00:03:01.800 --> 00:03:07.439 A:middle L:90%
pivot transition left and locomotion pivot transition. Right now

65
00:03:07.439 --> 00:03:08.900 A:middle L:90%
we want to populate these variables with the name hashes

66
00:03:08.909 --> 00:03:10.800 A:middle L:90%
and we've been doing that just right on our start

67
00:03:10.800 --> 00:03:19.110 A:middle L:90%
with so there we go. The next thing we

68
00:03:19.110 --> 00:03:20.949 A:middle L:90%
want to do is you want to add that code

69
00:03:22.039 --> 00:03:25.530 A:middle L:90%
to our pivot logic. So our pivot method currently

70
00:03:25.530 --> 00:03:30.099 A:middle L:90%
says if name hashes, pivot left I'd or right

71
00:03:30.099 --> 00:03:35.599 A:middle L:90%
idea. Let's add some logic to make that.

72
00:03:35.610 --> 00:03:38.259 A:middle L:90%
Also take into account the transitions. Mm hmm.

73
00:03:43.840 --> 00:03:46.590 A:middle L:90%
So that's good. Let's give that a shot and

74
00:03:46.590 --> 00:03:49.259 A:middle L:90%
see if that makes our our turns any more accurate

75
00:03:53.039 --> 00:03:54.030 A:middle L:90%
. We need to we need to declare transition and

76
00:03:54.030 --> 00:04:00.189 A:middle L:90%
Phil so transition info will be a new variable that

77
00:04:00.189 --> 00:04:01.550 A:middle L:90%
we're going to declare at the top of our script

78
00:04:02.840 --> 00:04:06.210 A:middle L:90%
and made a transition info that there we want to

79
00:04:06.210 --> 00:04:09.740 A:middle L:90%
initialize it at the same time. We initialize our

80
00:04:09.740 --> 00:04:12.360 A:middle L:90%
state info. And since we're just using the first

81
00:04:12.360 --> 00:04:14.509 A:middle L:90%
layer, you can just grab you can just put

82
00:04:14.509 --> 00:04:15.649 A:middle L:90%
a zero here. It's a signal that you just

83
00:04:15.649 --> 00:04:18.759 A:middle L:90%
want the first layer. Okay, hopefully that'll compile.

84
00:04:21.740 --> 00:04:23.959 A:middle L:90%
Okay, great, let's give that a shot

85
00:04:24.339 --> 00:04:26.870 A:middle L:90%
. hopefully we'll be getting values closer to to 180

86
00:04:26.870 --> 00:04:30.399 A:middle L:90%
now Instead of 1:30. So I was 1 78

87
00:04:30.399 --> 00:04:34.540 A:middle L:90%
. That was pretty good. 1 77. But

88
00:04:34.540 --> 00:04:36.600 A:middle L:90%
you notice it's still not quite right. The cameras

89
00:04:36.600 --> 00:04:40.290 A:middle L:90%
turning during the pivot. So we need to extend

90
00:04:40.290 --> 00:04:43.959 A:middle L:90%
this logic year and go into our camera script.

91
00:04:46.639 --> 00:04:48.430 A:middle L:90%
And where we have our behind camera want to add

92
00:04:48.430 --> 00:04:50.970 A:middle L:90%
one more condition to the look direction because the look

93
00:04:50.970 --> 00:04:54.360 A:middle L:90%
direction is going to affect that angle direction because if

94
00:04:54.360 --> 00:04:57.290 A:middle L:90%
you look in our controller script, we're grabbing the

95
00:04:57.290 --> 00:04:59.540 A:middle L:90%
cameras forward factors. So if we're turning the camera,

96
00:04:59.550 --> 00:05:00.649 A:middle L:90%
that forward vector is going to change. So

97
00:05:00.649 --> 00:05:03.509 A:middle L:90%
the easy way to fix that is just to give

98
00:05:03.509 --> 00:05:09.209 A:middle L:90%
it a condition, we're going to make that condition

99
00:05:09.420 --> 00:05:12.699 A:middle L:90%
that it's not in a pivot. So we added

100
00:05:12.699 --> 00:05:15.000 A:middle L:90%
this follow is not in pivot condition. So let's

101
00:05:15.000 --> 00:05:21.660 A:middle L:90%
see what that looks like. Now that's much better.

102
00:05:23.839 --> 00:05:26.439 A:middle L:90%
So we're getting nice values, they're large enough

103
00:05:26.610 --> 00:05:30.680 A:middle L:90%
and our cameras not turning what we're pivoting. That's

104
00:05:30.680 --> 00:05:31.490 A:middle L:90%
it's a pretty good win. And that's it for

105
00:05:31.490 --> 00:05:33.790 A:middle L:90%
this lesson. And then the next lesson we're going

106
00:05:33.790 --> 00:05:35.930 A:middle L:90%
to be discussing how to make a free camera.

107
00:05:35.939 --> 00:05:38.170 A:middle L:90%
So stay tuned for that.

