1
00:00:00,000 --> 00:00:00,000
Hello, guys.

2
00:00:00,000 --> 00:00:02,000
In this video, we're going to make lend animation.

3
00:00:02,000 --> 00:00:04,000
And first I want to explain how it's going to work.

4
00:00:04,000 --> 00:00:08,000
Lending going to be triggered when we get into the ground, but it's always like that.

5
00:00:08,000 --> 00:00:11,000
So we need some special condition to make lending special.

6
00:00:11,000 --> 00:00:17,000
So what I want to do is to make that if player going down really fast, if his velocity on the Y is

7
00:00:17,000 --> 00:00:23,000
negative, like -20 or something, then we can switch on boolean that he can roll on lending and when

8
00:00:23,000 --> 00:00:26,000
he touches the ground, animation will be triggered.

9
00:00:26,000 --> 00:00:27,000
So that's what we're going to do.

10
00:00:27,000 --> 00:00:29,000
Let's first create animation.

11
00:00:29,000 --> 00:00:32,000
Let's select player, create new clip.

12
00:00:33,000 --> 00:00:36,000
Animations player role.

13
00:00:37,000 --> 00:00:40,000
Then we go into animations or sorry, graphics.

14
00:00:41,000 --> 00:00:45,000
Should I Wait a second, I'll highlight the mouse.

15
00:00:46,000 --> 00:00:46,000
All right.

16
00:00:46,000 --> 00:00:49,000
So we're going to player find a role folder.

17
00:00:49,000 --> 00:00:51,000
And here we need roll animation.

18
00:00:51,000 --> 00:00:53,000
But not all of the sprites.

19
00:00:53,000 --> 00:00:55,000
Maybe from the second one.

20
00:00:55,000 --> 00:00:56,000
Yeah.

21
00:00:56,000 --> 00:00:57,000
We need these.

22
00:00:57,000 --> 00:01:01,000
Or even, you know what from the third one, because he's kind of flying from above.

23
00:01:01,000 --> 00:01:04,000
And then there is this and roll like that and stand up.

24
00:01:04,000 --> 00:01:06,000
Now let's try a sample rate.

25
00:01:07,000 --> 00:01:08,000
15.

26
00:01:10,000 --> 00:01:11,000
Think that's okay.

27
00:01:11,000 --> 00:01:13,000
Now we're going to animator.

28
00:01:13,000 --> 00:01:15,000
Let's create bowling.

29
00:01:15,000 --> 00:01:17,000
Ball can roll.

30
00:01:17,000 --> 00:01:19,000
Going to drag it above just like that.

31
00:01:20,000 --> 00:01:23,000
Place it here and we're going to do some changes here.

32
00:01:23,000 --> 00:01:30,000
We're going to make transition to roll from double jump if can roll through.

33
00:01:30,000 --> 00:01:40,000
And if he is grounded, sorry, is grounded through exit time and check, Duration zero, as always,

34
00:01:40,000 --> 00:01:43,000
then from jump fall, the very same.

35
00:01:43,000 --> 00:01:48,000
Plus plus can roll and is grounded and check zero.

36
00:01:48,000 --> 00:01:56,000
Then from player roll we do in transition to idol with exit time one and duration is zero.

37
00:01:56,000 --> 00:02:00,000
So we're just going to play animation once and then we're going back to Idol move.

38
00:02:00,000 --> 00:02:01,000
All right.

39
00:02:01,000 --> 00:02:05,000
Now let's select our transition from jump forward to Idol move and add here.

40
00:02:05,000 --> 00:02:07,000
Condition can roll false.

41
00:02:08,000 --> 00:02:09,000
Same for double jump.

42
00:02:09,000 --> 00:02:11,000
Can roll should be false.

43
00:02:11,000 --> 00:02:12,000
All right.

44
00:02:12,000 --> 00:02:13,000
We done with animator.

45
00:02:13,000 --> 00:02:15,000
Now let's go to player script.

46
00:02:15,000 --> 00:02:17,000
We're going to animator controllers.

47
00:02:17,000 --> 00:02:19,000
Let's find the function over here.

48
00:02:20,000 --> 00:02:23,000
And here we need to make just one if statement.

49
00:02:23,000 --> 00:02:34,000
So it will say if rb velocity dot y less than let's try -20 then anim set ball off can role will be

50
00:02:34,000 --> 00:02:35,000
set to true.

51
00:02:35,000 --> 00:02:41,000
While we are here, let's create a function private void role anim finished.

52
00:02:42,000 --> 00:02:49,000
And actually we can just return one line of code and said bull can roll to false.

53
00:02:50,000 --> 00:02:51,000
Let's go back to Unity.

54
00:02:52,000 --> 00:02:55,000
Find our player, find roll animation.

55
00:02:55,000 --> 00:02:59,000
Then we go into the last frame and we add event.

56
00:03:01,000 --> 00:03:02,000
Roll animation Finished.

57
00:03:03,000 --> 00:03:05,000
Let's go and test this.

58
00:03:06,000 --> 00:03:08,000
I prepared a level part for this.

59
00:03:08,000 --> 00:03:09,000
There's nothing special.

60
00:03:09,000 --> 00:03:11,000
Just a block so we can jump on the top.

61
00:03:11,000 --> 00:03:12,000
Let's go and see this.

62
00:03:13,000 --> 00:03:17,000
So I'm going to jump from the high ground and roll is there.

63
00:03:19,000 --> 00:03:20,000
Cool right now.

64
00:03:20,000 --> 00:03:25,000
There is one misbehavior we have and what I'm talking about, I'll show you right now.

65
00:03:25,000 --> 00:03:31,000
If I'll jump now and I'll do my left climb, my animation role will be triggered.

66
00:03:31,000 --> 00:03:32,000
So why is that?

67
00:03:32,000 --> 00:03:33,000
And what is happening?

68
00:03:33,000 --> 00:03:39,000
Actually, when we do in ledge climb, we did not switch of gravity scale of the player and he's always

69
00:03:39,000 --> 00:03:41,000
pulled down.

70
00:03:41,000 --> 00:03:44,000
We just sit in his position over here.

71
00:03:44,000 --> 00:03:45,000
Let me find it.

72
00:03:47,000 --> 00:03:48,000
Ronald Reagan.

73
00:03:48,000 --> 00:03:49,000
Yeah.

74
00:03:49,000 --> 00:03:54,000
We sit in his position to climb big and position all the time, but we did not switch of his gravity.

75
00:03:54,000 --> 00:04:01,000
So he's getting pulled down all the time and his velocity in the rigid body over here, you can, you

76
00:04:01,000 --> 00:04:07,000
can go to a rigid body in four and you can find his way velocity over here.

77
00:04:08,000 --> 00:04:08,000
Yeah.

78
00:04:09,000 --> 00:04:14,000
So we can see his negative velocity is always negative when he's doing that.

79
00:04:14,000 --> 00:04:16,000
Let me try to show you again.

80
00:04:17,000 --> 00:04:20,000
Look here at the velocity on the Y.

81
00:04:22,000 --> 00:04:23,000
That was negative, Right?

82
00:04:23,000 --> 00:04:24,000
I'll try again.

83
00:04:27,000 --> 00:04:28,000
It is negative.

84
00:04:28,000 --> 00:04:31,000
Going down, down, down, down, down, down, down, down.

85
00:04:31,000 --> 00:04:31,000
You see?

86
00:04:31,000 --> 00:04:34,000
Minus eight and so on.

87
00:04:35,000 --> 00:04:39,000
And reaching up to -16, sometimes even more if you jump from the high ground.

88
00:04:46,000 --> 00:04:53,000
Okay, My velocity is -12 now because I jumped from the high ground now, which it's going down, down

89
00:04:53,000 --> 00:04:56,000
more and more and more and more and more and more and.

90
00:04:57,000 --> 00:04:59,000
Up to -40, I can see now.

91
00:04:59,000 --> 00:05:05,000
So what we can do here, we can just switch off the gravity scale while we're doing ledge climb.

92
00:05:05,000 --> 00:05:06,000
That will be very simple.

93
00:05:06,000 --> 00:05:14,000
Once we grab the ledge, we're going to set RB dot velocity or sorry, rb rb dot gravity scale equals

94
00:05:14,000 --> 00:05:15,000
to zero.

95
00:05:17,000 --> 00:05:19,000
And our default gravity scale is five.

96
00:05:19,000 --> 00:05:28,000
It's over here so we can go back to code and when Ledge climb is over, we're going to do our gravity

97
00:05:28,000 --> 00:05:30,000
scale equals to five.

98
00:05:31,000 --> 00:05:33,000
Now let's try that again.

99
00:05:33,000 --> 00:05:38,000
And now roll is not triggered after ledge climb, but it's triggered after a jump from the high ground.

100
00:05:38,000 --> 00:05:40,000
Now we can go to the next video.

