Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,740 --> 00:00:03,710
Now let's implement jumping logics in our game.
2
00:00:03,710 --> 00:00:07,000
There's two kinds of gravity systems we can implement.
3
00:00:07,190 --> 00:00:13,490
Either we can have a constant gravity meaning that as you can see from the first picture the number
4
00:00:13,490 --> 00:00:20,320
of frames of Maya reaching the highest point while jumping equals to the same amount of frames for Mario
5
00:00:20,330 --> 00:00:28,970
falling to the ground in the second example you can see that the gravity is at a variable intensity.
6
00:00:28,970 --> 00:00:35,710
So when Mario is jumping upwards the gravity is less intense than when Mario is falling.
7
00:00:35,720 --> 00:00:40,370
Most Mario games use gravity at a variable intensity.
8
00:00:40,370 --> 00:00:46,850
First let's implements the constant gravity system and then let's implement the variable intensity gravity
9
00:00:46,850 --> 00:00:56,960
system let's head back to unity we select or player logic and first we need to implement the jump height
10
00:01:01,870 --> 00:01:11,840
for this we will use zero point five f then we will also need to implement a variable for gravity let's
11
00:01:11,840 --> 00:01:22,490
use this for now and we also need to add a boolean to track when we're jumping in the update function
12
00:01:22,850 --> 00:01:34,830
we will check whether the player is jumping or not so we can say if the player is not jumping and input
13
00:01:35,030 --> 00:01:38,200
get button down jump
14
00:01:41,060 --> 00:01:42,680
then jump is true
15
00:01:49,680 --> 00:01:52,550
and then in a fixed update willing to apply to gravity.
16
00:01:53,140 --> 00:01:57,330
So what we can say is if the character is not on the ground.
17
00:01:57,370 --> 00:02:04,270
So when he's in the air for this we can do character controller is grounded and in this case I say if
18
00:02:04,270 --> 00:02:15,020
the character controller is not grounded then we are going to reduce the gravity from his movement.
19
00:02:15,020 --> 00:02:26,200
Why else he if he is standing on the ground we're going to set movement y to zero and if the player
20
00:02:26,200 --> 00:02:27,010
is jumping
21
00:02:30,480 --> 00:02:39,380
First we will set the jumping to false and we will set his movement height to a specific value.
22
00:02:42,910 --> 00:02:49,800
Equals to the jump height so all we're doing right now is here we are applying to gravity
23
00:02:53,280 --> 00:02:55,260
and here we are.
24
00:02:58,220 --> 00:03:02,280
Adding jump to movement y.
25
00:03:05,320 --> 00:03:12,460
Setting setting jump height to movement height is better okay.
26
00:03:12,550 --> 00:03:13,690
Let's try it isn't a game.
27
00:03:16,040 --> 00:03:21,460
So now if your press play I move my character and I press base.
28
00:03:21,500 --> 00:03:30,590
The character will jump if I want him to jump higher or lower I can simply tweak to values.
29
00:03:30,850 --> 00:03:32,620
I just have to change my variables.
30
00:03:32,620 --> 00:03:41,650
I can increase or decrease my jump pints and I can increase or decrease my gravity if I save and then
31
00:03:41,740 --> 00:03:42,850
run it again.
32
00:03:42,970 --> 00:03:48,790
You will see that the jumping results will be different.
33
00:03:48,890 --> 00:03:53,000
Now he jumps slightly higher and falls a little bit faster.
34
00:03:54,850 --> 00:04:01,960
Now as you can see the time it takes for the player to reach the top point in his jump is the same time
35
00:04:01,960 --> 00:04:04,020
it takes for him to fall down.
36
00:04:04,060 --> 00:04:13,840
Let's say we want to have a variable gravity intensity while what we could do then is we can check if
37
00:04:14,480 --> 00:04:20,230
a movement or Y is bigger than zero which means we are jumping
38
00:04:24,330 --> 00:04:36,320
then we can just apply regular gravity and if movement or Y is less than zero then we can do the same
39
00:04:36,350 --> 00:04:40,240
but we can multiply the gravity.
40
00:04:40,480 --> 00:04:46,670
For example one point five so 50 percent increase in gravity.
41
00:04:46,720 --> 00:04:56,290
So now if we're going back to our game we jump normally the character will fall much faster as you can
42
00:04:56,290 --> 00:04:59,480
see he's falling faster now.
43
00:05:01,960 --> 00:05:06,000
After reaching his stop point in the jump okay.
44
00:05:06,070 --> 00:05:07,180
That's it for jumping.
4474
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.