Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:05,830 --> 00:00:10,220
In this video we're going to take a look at why we're moving so quickly to the right.
2
00:00:10,260 --> 00:00:15,480
When we type transform not translate vector 3D outright in order to understand this we have to understand
3
00:00:15,480 --> 00:00:17,310
how update is working.
4
00:00:17,340 --> 00:00:24,960
Update is called once per frame typically about 60 frames per second vector 3D out right is the equivalent
5
00:00:24,960 --> 00:00:26,700
of typing new vector 3.
6
00:00:26,850 --> 00:00:30,060
Unit on the x 0 in 0 on the wife Z.
7
00:00:30,270 --> 00:00:35,670
When we say one unit in unity that's the equivalent of one meter in the real world.
8
00:00:36,930 --> 00:00:45,060
So what's happening here is we're moving our player to the right one meter per frame 60 meters per second
9
00:00:45,420 --> 00:00:51,320
what we actually want to do is move our player to the right one meter per second.
10
00:00:51,630 --> 00:00:57,510
So we need to do is we need to convert one meter per frame to one meter per second in the way we do
11
00:00:57,510 --> 00:01:06,290
that is by incorporating real time and to do that we multiply the vector by time delta time time no
12
00:01:06,310 --> 00:01:12,030
doubt the time is going to do the conversion process from frame rate dependent to real minutes seconds
13
00:01:12,030 --> 00:01:17,170
and hours for us time not total time can be thought of as one second.
14
00:01:17,400 --> 00:01:26,830
So if we actually were to run this and we actually were to play this you'll see here that we are now
15
00:01:26,830 --> 00:01:35,020
moving one meter per second to the right and we can actually witness our character moving the technical
16
00:01:35,020 --> 00:01:40,900
term for time not that the time is really the time and seconds it took to complete the last frame to
17
00:01:40,900 --> 00:01:47,860
the current frame and in reality what's really happening here is it allows us to use real time.
18
00:01:47,860 --> 00:01:53,950
So if I needed to create for example a five second timer I could just add timed I don't the time to
19
00:01:53,950 --> 00:01:56,800
a variable and check it for five seconds.
20
00:01:56,800 --> 00:02:03,700
This is the equivalent of incorporating real time into use it you simply just multiply it by a vector.
21
00:02:03,790 --> 00:02:09,100
Now what I want to get into next is how can we move five meters per second.
22
00:02:09,100 --> 00:02:11,800
Well right now we're moving one meter per second.
23
00:02:11,800 --> 00:02:17,710
All I have to do to move five meters per second would be to multiply our vector three not right by five
24
00:02:18,070 --> 00:02:21,460
and then multiply that by timed out delta time.
25
00:02:21,520 --> 00:02:29,520
This is going to convert to five meters per second if we hop into unity once our code is compiled I
26
00:02:29,520 --> 00:02:36,500
can run the application and you'll see here that we are now moving five meters per second.
27
00:02:37,320 --> 00:02:39,610
Now how does that work and why does that work.
28
00:02:39,960 --> 00:02:46,530
Well this comes down to something in mathematics called the distributive property and what it does is
29
00:02:46,530 --> 00:02:54,130
you can see here that we have vector three right multiplied by five multiplied by real time.
30
00:02:54,140 --> 00:02:58,350
And what's happening here is basically what's on the side of the parentheses is getting multiplied by
31
00:02:58,350 --> 00:03:00,060
what's inside the parentheses.
32
00:03:00,060 --> 00:03:06,450
So here we have 1 times 5 which becomes 5 and then we multiply that by real time.
33
00:03:06,450 --> 00:03:08,720
So we're moving five units to the right.
34
00:03:08,760 --> 00:03:11,740
Anything multiplied by zero stays zero.
35
00:03:11,760 --> 00:03:15,630
What happens if I change this to vector three dot left.
36
00:03:15,630 --> 00:03:21,870
Well if I change that to vector three about left that's the equivalent of typing new vector three negative
37
00:03:21,870 --> 00:03:30,390
one and then still I have a five here so negative 1 times 5 is going to be negative 5 0 times 5 is going
38
00:03:30,390 --> 00:03:34,120
to be 0 in 0 times 5 on the Z is going to be zero.
39
00:03:34,140 --> 00:03:42,630
So now we're moving negative 5 units to the left per second because we're using real time.
40
00:03:42,630 --> 00:03:47,990
So I hope that makes sense to you go ahead and test it out and you should be able to move me just for
41
00:03:47,990 --> 00:03:52,890
a second in the next video we'll take a look at creating our first variable.
4817
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.