All language subtitles for 003 Start() & Update()_Downloadly.ir_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified) Download
zh-TW Chinese (Traditional) Download
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
ia Interlingua
ga Irish
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:03,180 --> 00:00:07,350 In this video, we're going to talk about the difference between start and update and just create a 2 00:00:07,350 --> 00:00:13,530 little piece of code that allows us to move our object up every frame that the game is playing. 3 00:00:13,620 --> 00:00:14,910 OK, let's jump in and get started. 4 00:00:15,090 --> 00:00:17,090 Let's make sure you're awake and ready for action. 5 00:00:17,100 --> 00:00:20,000 I'm going to start you off with a challenge to get the party started. 6 00:00:20,010 --> 00:00:26,550 In other words, create a new 3D project within unity at a ground plane, create your player. 7 00:00:26,550 --> 00:00:29,400 So add in a cube or a circle or sphere. 8 00:00:29,400 --> 00:00:33,570 Whatever you think would be cool for your player are going to be adding a cube and then to rename your 9 00:00:33,570 --> 00:00:33,980 player. 10 00:00:33,990 --> 00:00:37,250 So pause the video, take on that challenge and I'll see you back here when you're done. 11 00:00:38,540 --> 00:00:43,040 OK, step one, open up the unity hub, I'm going to click on you to create a new project. 12 00:00:43,220 --> 00:00:49,670 This will be with twenty twenty point one for me, three day project I'm going to name this obstacle 13 00:00:49,670 --> 00:00:50,170 course. 14 00:00:50,180 --> 00:00:53,840 Doesn't matter so much what you've named yours, but that's what I'm naming mine. 15 00:00:54,170 --> 00:00:56,210 And for me, I'll add that to my repos. 16 00:00:56,210 --> 00:00:57,980 Unity, 3D location. 17 00:00:57,980 --> 00:01:01,040 So click on Create that will create our unity project. 18 00:01:01,040 --> 00:01:05,750 So give that a moment or two that will bring us to our template project. 19 00:01:05,750 --> 00:01:11,770 I'm going to right click in my hierarchy and add a 3D object and this will be a plane block. 20 00:01:11,840 --> 00:01:12,510 There we go. 21 00:01:12,920 --> 00:01:16,460 Not exactly sure how big I'll need this yet, so I'll leave it as it is for the moment. 22 00:01:16,460 --> 00:01:19,190 The next thing I'm going to do is create myself a player. 23 00:01:19,190 --> 00:01:20,150 So right. 24 00:01:20,150 --> 00:01:22,220 Click 3D object. 25 00:01:22,220 --> 00:01:25,610 I'll make a cube, see the cubes a little bit underneath the ground plane. 26 00:01:25,640 --> 00:01:28,370 So just bring that up slightly, OK? 27 00:01:28,370 --> 00:01:30,890 And to give it a little bit of personality, I'm going to squash it down. 28 00:01:30,890 --> 00:01:34,370 So on to scale squash, squash and then just move it. 29 00:01:34,370 --> 00:01:36,860 So it's touching the ground ish again. 30 00:01:37,070 --> 00:01:37,540 There we go. 31 00:01:37,540 --> 00:01:41,870 Right now I'm going to rename my cue by clicking on Cueball clicking over in the Inspector. 32 00:01:42,080 --> 00:01:44,000 I will rename that to be what I say. 33 00:01:44,000 --> 00:01:45,170 I was going to call it dodgy. 34 00:01:45,170 --> 00:01:49,540 Dodgy the player not because he's untrustworthy, just because he's good at he's nimble. 35 00:01:49,550 --> 00:01:50,030 There we go. 36 00:01:50,180 --> 00:01:52,340 And that should be where you're up to from your challenge. 37 00:01:52,340 --> 00:01:52,610 Yep. 38 00:01:52,610 --> 00:01:53,900 There are all the steps in the challenge. 39 00:01:53,960 --> 00:01:57,560 Now, the purpose of this video is to show you the difference between start and update. 40 00:01:57,560 --> 00:01:59,360 So to do that, we need to get some code. 41 00:01:59,360 --> 00:02:00,680 We need to create ourselves a script. 42 00:02:00,680 --> 00:02:02,090 So little micro challenge for you. 43 00:02:02,090 --> 00:02:04,880 Go ahead and create a new script called Movea. 44 00:02:06,440 --> 00:02:11,420 OK, so if you're not exactly sure, we'll do that together, right, click down in our project assets 45 00:02:11,420 --> 00:02:17,350 folder up to create and see sharp script before we click anywhere else, I'm going to rename this Movea. 46 00:02:17,660 --> 00:02:21,580 Or I guess if you're in North America mover, I should have pronounced it mover. 47 00:02:22,070 --> 00:02:25,340 This is the script that's going to move our player. 48 00:02:25,460 --> 00:02:26,260 You guessed it. 49 00:02:26,660 --> 00:02:31,610 Now we've got three different ways we can attach our script to our player, which is an important thing 50 00:02:31,610 --> 00:02:37,130 to do because we want to be moving the player itself and we need this script attached to it to do so. 51 00:02:37,140 --> 00:02:44,120 So method number one is I could click on my player dog and not just so it's very clear I'm going to 52 00:02:44,120 --> 00:02:47,750 rename this player and then in parentheses, dodgy. 53 00:02:47,750 --> 00:02:52,280 Just so anyone who joins this project midway through, they're not completely confused about what on 54 00:02:52,280 --> 00:02:53,540 earth a dog is. 55 00:02:53,710 --> 00:02:55,210 It's a player whose name is Dog. 56 00:02:55,220 --> 00:02:55,730 There we go. 57 00:02:55,730 --> 00:02:56,750 So, well, we clicked on that. 58 00:02:56,750 --> 00:03:04,910 I can drag Movea over into my Inspecteur that will add it there, or I can drag on top of the object 59 00:03:04,910 --> 00:03:13,280 in my hierarchy, or I can click on add component and type in mover and click to add that way. 60 00:03:13,280 --> 00:03:14,750 So I'll do that final method. 61 00:03:14,750 --> 00:03:20,450 But just showing a few different ways that you can add a script as a component onto a game object. 62 00:03:20,730 --> 00:03:25,520 Now we want to open up movies or double click on that should open up visual studio code. 63 00:03:25,640 --> 00:03:27,410 You can see well I've got this open here. 64 00:03:27,410 --> 00:03:29,360 I'm going to minimize the left hand side in a moment. 65 00:03:29,360 --> 00:03:30,800 Let me just do a little bit of rearranging. 66 00:03:30,980 --> 00:03:34,970 You can see that it will show us the script in our file. 67 00:03:34,970 --> 00:03:36,080 Explorer, you can see. 68 00:03:36,080 --> 00:03:36,410 Move it. 69 00:03:36,410 --> 00:03:36,710 You see. 70 00:03:36,710 --> 00:03:39,170 So if we have a whole bunch of scripts, you'll see them lined up in there. 71 00:03:39,410 --> 00:03:41,150 Now, I'm just going to click to close that box. 72 00:03:41,150 --> 00:03:43,010 I don't need to see that extra piece of information. 73 00:03:43,160 --> 00:03:46,250 Now, there's a lot going on in this script, but we're just going to focus on a couple of things for 74 00:03:46,250 --> 00:03:49,250 now and as we go, will expand and we'll get to all of these various things. 75 00:03:49,250 --> 00:03:49,970 Don't worry about that. 76 00:03:49,970 --> 00:03:53,150 But we're focusing on the fact that we have stopped and we have update. 77 00:03:53,450 --> 00:03:59,650 Now, what unity is doing is saying anything that is within start, anything that we write in here, 78 00:03:59,660 --> 00:04:02,690 any statements I will make, those statements happen. 79 00:04:02,690 --> 00:04:08,990 I'll do those statements when this script first comes to life and I'll do them just once. 80 00:04:09,380 --> 00:04:16,370 Update is something that it says I will do every single frame that this script is alive and within the 81 00:04:16,370 --> 00:04:16,760 game. 82 00:04:16,910 --> 00:04:18,110 What I mean by frame, will you? 83 00:04:18,140 --> 00:04:22,220 I'm sure you've played a game and you've seen that it's 30 or 60 fps. 84 00:04:22,220 --> 00:04:27,830 In other words, frames per second a frame is something that is calculating all of the things that need 85 00:04:27,830 --> 00:04:30,650 to go on in your game and make those happen. 86 00:04:30,650 --> 00:04:33,830 So it might say, OK, we need to move this character a little bit. 87 00:04:33,830 --> 00:04:35,480 There might be another character over a little bit. 88 00:04:35,570 --> 00:04:37,370 There might be some logic on some AI. 89 00:04:37,460 --> 00:04:42,110 And all of those things are happening many, many, many times per second, because if they only happen 90 00:04:42,110 --> 00:04:47,990 once per second, you're going to be like boing, boing, boing like that, be very jumpy and jerky. 91 00:04:48,170 --> 00:04:49,880 So that's why things are happening a lot. 92 00:04:49,880 --> 00:04:54,740 Every single frame sometimes is called a tick because it's happening on a regular basis. 93 00:04:54,890 --> 00:04:59,990 But every single frame of our game, things happen in every single frame of our game. 94 00:05:00,320 --> 00:05:03,530 Whatever we say to do in the update will be done. 95 00:05:03,800 --> 00:05:08,450 Now, let's make this a little bit concrete, so let's have a look at our player dog as mine is cold. 96 00:05:08,630 --> 00:05:13,850 And you can see that while I've clicked on w my move here, I can move it around. 97 00:05:13,850 --> 00:05:15,080 What's happening when I move it around. 98 00:05:15,080 --> 00:05:18,830 Well over now Inspector, you can see the transform values are moving. 99 00:05:18,830 --> 00:05:24,830 So if I was to rotate my screen a little bit here, so we've got the read which relates to X to the 100 00:05:24,830 --> 00:05:27,830 right and the Y is up in the Z is going into the screen. 101 00:05:27,950 --> 00:05:32,780 You can see as I move to the right, the X value is increasing. 102 00:05:32,960 --> 00:05:36,470 If I move to the left, the X value is decreasing. 103 00:05:36,470 --> 00:05:40,730 And I can also come over here into the inspector and I could type in, say, zero, for example, that 104 00:05:40,730 --> 00:05:42,710 will make this go exactly to zero. 105 00:05:42,710 --> 00:05:49,460 Or I could mouse over the X or the Y or Z and I can click my mouse and slide along like this. 106 00:05:49,460 --> 00:05:55,560 So you can see this is literally saying set the position in the world, two point forty four. 107 00:05:55,670 --> 00:06:00,440 Now we're saying set it to, for example, minus two and we can do the same on the Y axis. 108 00:06:00,440 --> 00:06:05,240 So set it to two and on the Z axis, set it to one, for example. 109 00:06:05,400 --> 00:06:10,730 OK, now if you wanted to get right back to the centre again, we can put zero zero zero. 110 00:06:10,730 --> 00:06:12,480 I'm just having to move between those now. 111 00:06:12,500 --> 00:06:15,230 It's underground again so I can lift it back out of the ground. 112 00:06:15,860 --> 00:06:21,020 OK, now I'm hammering this point home that as we move our object, these values are moving because 113 00:06:21,020 --> 00:06:23,930 we're about to change that encode in our script. 114 00:06:24,080 --> 00:06:32,270 So if we're back into our movie script, if we add into our START method something that allows us to 115 00:06:32,270 --> 00:06:41,660 change the transform value, and the way we do this is to start by typing transform with a small t dot. 116 00:06:43,060 --> 00:06:48,760 Translate with a large tea or capital tea and then open parentheses. 117 00:06:48,940 --> 00:06:51,430 Let me just take a moment just to let you know what's going on here. 118 00:06:51,440 --> 00:06:56,850 So transform means we are accessing the transform of this game object. 119 00:06:56,860 --> 00:06:58,230 Why do I say this game object? 120 00:06:58,240 --> 00:07:06,460 Well, we have put Movea dot seats onto our player, so when it's looking for transform, it's saying, 121 00:07:06,460 --> 00:07:09,640 OK, the transform of the game object that I'm currently on. 122 00:07:09,670 --> 00:07:14,200 So that's this component over here, this transform, it's the transform on our game object. 123 00:07:14,440 --> 00:07:15,880 And we have in here a dot. 124 00:07:15,880 --> 00:07:21,880 Now that's the dot operator which allows us to access something that is contained within transform or 125 00:07:21,880 --> 00:07:28,090 is underneath transform or is some set of logic that we get by accessing transform. 126 00:07:28,090 --> 00:07:34,030 And in this case, unity has a built in method which is translate, which basically means move. 127 00:07:34,210 --> 00:07:36,610 OK, translate that's already created for us. 128 00:07:36,610 --> 00:07:37,600 We get it for free. 129 00:07:37,600 --> 00:07:42,430 It's one of the joys of using an engine some hard working engineer in Silicon Valley has created. 130 00:07:42,450 --> 00:07:43,780 Translate for us to use. 131 00:07:43,780 --> 00:07:44,130 Excellent. 132 00:07:44,320 --> 00:07:45,520 And what are the rules of translate? 133 00:07:45,520 --> 00:07:52,180 Well, what translate needs is for us to say where do you want me to go on the X and the Y and Z? 134 00:07:52,180 --> 00:07:59,500 And you need to type that by saying X, Y, Z, except it won't know what X, Y and Z are. 135 00:07:59,530 --> 00:08:02,820 They just representations it needs to see a number. 136 00:08:02,830 --> 00:08:09,070 So what will go in here and change instead of X will say one instead of Y will say zero instead of Z 137 00:08:09,100 --> 00:08:10,030 will say zero. 138 00:08:10,180 --> 00:08:13,240 And then at the end of our statement we need to add a semicolon. 139 00:08:13,720 --> 00:08:17,920 So I'm going to put my values back here to zero zero zero just for argument's sake, so we can see what 140 00:08:17,920 --> 00:08:18,340 happens. 141 00:08:18,530 --> 00:08:21,010 What we're saying is add to that. 142 00:08:21,010 --> 00:08:23,410 We're not saying take it to one zero zero. 143 00:08:23,410 --> 00:08:26,940 We're saying add one, add zero, add zero. 144 00:08:27,070 --> 00:08:29,050 OK, so I'm going to click on Save. 145 00:08:29,080 --> 00:08:30,370 OK, back into Unity. 146 00:08:30,370 --> 00:08:35,650 Now, what I'm going to do is to make this easier to see is grab my green in my game window and move 147 00:08:35,650 --> 00:08:37,600 that just next to the scene window. 148 00:08:37,600 --> 00:08:42,700 So I have the two side by side that will allow me to stay looking in the same view and also see what 149 00:08:42,700 --> 00:08:43,809 the camera is saying. 150 00:08:44,039 --> 00:08:47,110 So when I click on play, notice what happens to the cube. 151 00:08:47,950 --> 00:08:52,970 It goes jump to the right and how much of that jump to the right leg jumped one to the right? 152 00:08:53,140 --> 00:08:57,740 So if I click on play, you'll see it returns back to zero, back to where things started out. 153 00:08:57,910 --> 00:09:03,100 So that was us putting this simple, hey, move the cube or move the game object into stock. 154 00:09:03,280 --> 00:09:05,210 What would happen if we put it into update? 155 00:09:05,230 --> 00:09:06,120 Well, let's check that out. 156 00:09:06,460 --> 00:09:11,620 If I highlight, highlight, highlight my transformed work translate and then cut on my keyboard. 157 00:09:11,630 --> 00:09:17,530 So control X or command X and then paste control V, Command V to put this into update. 158 00:09:17,680 --> 00:09:22,630 Now what we're saying is do this particular thing every single frame. 159 00:09:22,780 --> 00:09:28,810 So if my computer is currently running at 60 frames per second, we'll move this one on the x axis 60 160 00:09:28,810 --> 00:09:29,830 times per second. 161 00:09:29,840 --> 00:09:32,920 So I'm going to hit save jump back over here. 162 00:09:32,920 --> 00:09:36,760 I'm just going to reorient my camera a little bit because I have a feeling this is going to go flying 163 00:09:36,760 --> 00:09:37,550 really fast. 164 00:09:37,550 --> 00:09:38,680 And when I click on play. 165 00:09:39,960 --> 00:09:46,140 Brewing goes off into the distance because it's moving every single frame, a one on the positive x 166 00:09:46,140 --> 00:09:46,560 axis. 167 00:09:46,920 --> 00:09:48,420 And one last thing before we move on. 168 00:09:48,450 --> 00:09:51,370 I'm just going to make this a smaller increment so we can see it more easily. 169 00:09:51,390 --> 00:09:58,200 So, for example, zero point zero one, if I save that, jump back over into unity, click on play. 170 00:09:58,200 --> 00:09:59,670 You can see that we have an error. 171 00:09:59,700 --> 00:10:00,060 Excellent. 172 00:10:00,060 --> 00:10:01,470 I'm glad it gave me that error there. 173 00:10:01,590 --> 00:10:03,090 If we if you see an error. 174 00:10:03,090 --> 00:10:08,010 So if any time it says, oh, compiler error, this won't work, then what you need to do is jump into 175 00:10:08,010 --> 00:10:10,230 the console and have a look to see what it is saying. 176 00:10:10,450 --> 00:10:14,630 OK, saying that we have an argument one cannot convert double to float. 177 00:10:14,640 --> 00:10:15,170 Excellent. 178 00:10:15,180 --> 00:10:20,190 So this is what I was hoping would happen, is because not all numbers are created equal, there's different 179 00:10:20,190 --> 00:10:22,080 types of representation of numbers. 180 00:10:22,230 --> 00:10:26,880 What Unity is expecting in this instance is a floating point value or a float. 181 00:10:27,120 --> 00:10:30,820 And to represent that, we need to put an F. after our numbers. 182 00:10:30,820 --> 00:10:36,690 So for zero point zero, where they need to put an F. to say this is a float and it's not going to get 183 00:10:36,690 --> 00:10:41,970 confused in theory, we should be putting them after the zero and after the zero as well. 184 00:10:41,970 --> 00:10:43,350 So it's very clear what's going on. 185 00:10:43,470 --> 00:10:46,290 But because there's no dot in there, there's no decimal place. 186 00:10:46,290 --> 00:10:48,240 Unity is like I call, I've got it. 187 00:10:48,240 --> 00:10:49,650 I know what you're talking about here, Rick. 188 00:10:49,770 --> 00:10:51,120 It's just a straight up zero. 189 00:10:51,270 --> 00:10:55,920 But when we've got our decimal place, it's a bit confusing and hit save back over into unity. 190 00:10:56,070 --> 00:10:58,410 Watch to see if my issue goes away. 191 00:10:58,410 --> 00:10:59,100 Yes, it does. 192 00:10:59,100 --> 00:11:00,300 That error has gone away. 193 00:11:00,450 --> 00:11:01,800 Click on play. 194 00:11:02,860 --> 00:11:07,600 And now you can see we're moving at a more reasonable pace, so the reason I wanted to take you through 195 00:11:07,600 --> 00:11:12,490 this was to show the difference between START, which is happening once, just when that script starts 196 00:11:12,490 --> 00:11:17,140 or in our case, when we click on play for the game versus update, which is happening every frame. 197 00:11:17,140 --> 00:11:22,360 And also to show you that this is the foundation for movement for our player, that we need to be having 198 00:11:22,360 --> 00:11:28,090 something within update that says every single frame, I might wish to move my player and move it in 199 00:11:28,090 --> 00:11:28,960 a particular spot. 200 00:11:29,140 --> 00:11:33,040 Just so we've anchored that mechanism of movement is going to be taking place within update. 201 00:11:33,280 --> 00:11:34,230 OK, good stuff. 202 00:11:34,270 --> 00:11:35,410 Hope this all made sense. 203 00:11:35,420 --> 00:11:39,970 If there's any questions at all, please throw your questions in the Q&A or the discussions and I'll 204 00:11:39,970 --> 00:11:41,050 see you in the next lecture. 20257

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.