All language subtitles for 10. Challenge Review User Input

af Afrikaans
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:04,450 --> 00:00:10,530 And this challenge review we're gonna take a look at how to hook up the vertical input the way we could 2 00:00:10,530 --> 00:00:15,160 do this is we need to create a variable that's going to store the vertical input. 3 00:00:15,420 --> 00:00:21,540 So we'll create another variable of type float and we'll call this vertical input from here. 4 00:00:21,540 --> 00:00:28,620 We're going to assign it to the input manager if I type input dot get access and then vertical this 5 00:00:28,620 --> 00:00:33,780 name has to match exactly what is inside the project settings. 6 00:00:33,780 --> 00:00:37,080 So if I check in and go to edit project settings 7 00:00:40,970 --> 00:00:47,360 and then go to input you'll see here that the vertical access is called vertical with a capital V that's 8 00:00:47,360 --> 00:00:52,270 going to return a float value based on zero and negative 1 or negative on the positive one. 9 00:00:53,720 --> 00:00:59,010 Now that I have that vertical input I can begin re typing out a new transform translate line. 10 00:00:59,210 --> 00:01:03,080 A common mistake with new developers is that they copy and paste code. 11 00:01:03,080 --> 00:01:08,720 Stop copying and pasting code if you copy and paste code at an early stage you are setting yourself 12 00:01:08,720 --> 00:01:09,940 up for failure. 13 00:01:09,950 --> 00:01:15,620 Programming is a skill that takes practice and over time you'll become very experienced if you write 14 00:01:15,620 --> 00:01:16,730 out your code. 15 00:01:16,730 --> 00:01:22,340 Oftentimes we will see people do in this challenge is to go ahead and just copy this line paste it and 16 00:01:22,340 --> 00:01:25,620 they will swap out the horizontal input with the vertical input. 17 00:01:25,640 --> 00:01:28,320 However it didn't work and they'll ask me why. 18 00:01:28,550 --> 00:01:33,550 Well I have one thing to say to them and every time they say yeah did you copy and paste it. 19 00:01:33,950 --> 00:01:39,680 And if you hadn't done that you'd recognize that you shouldn't have added vector through dot right. 20 00:01:39,680 --> 00:01:44,920 You could have avoided that had you just typed out the code and started correctly. 21 00:01:44,930 --> 00:01:49,580 I always recommend you type out your code never copy and paste anything you see. 22 00:01:49,730 --> 00:01:50,660 Always write it out. 23 00:01:50,660 --> 00:01:54,010 Try to understand it with practice and experience. 24 00:01:54,020 --> 00:01:59,490 You will get better and become a great software engineer so to do this I'm going to type out transform 25 00:01:59,490 --> 00:02:05,920 not translate open my parentheses in the vector 3 translation instead of going left and right. 26 00:02:05,960 --> 00:02:07,430 I want to go up and down. 27 00:02:07,640 --> 00:02:15,770 So I'm going to say vector three dot up multiplied by my vertical input multiplied by the speed and 28 00:02:15,770 --> 00:02:19,310 then I'm going to incorporate it all with real time. 29 00:02:19,310 --> 00:02:27,110 If I save this and hop back into unity like Unity compile will run this and I can now move up down left 30 00:02:27,110 --> 00:02:30,320 and right using the arrow keys as well as the WSJ keys. 31 00:02:32,700 --> 00:02:39,200 You'll see here if I run unity we can now move left and right up and down. 32 00:02:39,510 --> 00:02:43,060 We've successfully created user input movement. 33 00:02:43,230 --> 00:02:46,110 Now you may be wondering is there a way to optimize this. 34 00:02:46,110 --> 00:02:47,600 And is this the best approach. 35 00:02:47,670 --> 00:02:50,050 And that's the beautiful thing about programming. 36 00:02:50,100 --> 00:02:52,770 There is always more than one way to solve a problem. 37 00:02:52,830 --> 00:02:57,150 And throughout this course you're going to come through several challenges that are going to challenge 38 00:02:57,150 --> 00:02:59,930 you to come up with your own unique implementation of things. 39 00:02:59,970 --> 00:03:04,560 And what I want you to do throughout this entire course is use your implementation. 40 00:03:04,560 --> 00:03:06,720 Don't copy and paste what I type. 41 00:03:06,720 --> 00:03:08,220 I want you to use your code. 42 00:03:08,220 --> 00:03:12,250 Everyone who goes through this course should have a unique code base that's unique to them. 43 00:03:12,450 --> 00:03:15,690 To truly become a great software engineer you need to go through trial and error. 44 00:03:15,690 --> 00:03:17,970 You need to experience things in programming. 45 00:03:17,970 --> 00:03:20,400 There is no wrong or right way to do things. 46 00:03:20,430 --> 00:03:24,570 There are more optimal ways but there is never a wrong way to do things. 47 00:03:24,630 --> 00:03:30,240 And again there is always always more than one way to solve a problem. 48 00:03:30,270 --> 00:03:33,840 If I wanted to convert this into one line I could absolutely do that. 49 00:03:33,840 --> 00:03:35,880 I'm controlling the x axis here. 50 00:03:35,970 --> 00:03:39,820 The y axis here I could just put it into a new vector 3. 51 00:03:39,990 --> 00:03:44,580 So what I'm gonna do is I'm going to show you and it's OK to keep this implementation if this is the 52 00:03:44,580 --> 00:03:45,530 implementation you have. 53 00:03:45,540 --> 00:03:50,310 You can keep this or you can go along with the more optimized way but I encourage you to keep what you 54 00:03:50,310 --> 00:03:54,600 have but what we could have done is I could have said transform not translate. 55 00:03:55,320 --> 00:03:57,500 And then here it's asking for a vector 3. 56 00:03:57,510 --> 00:04:04,710 Well I could pass in a new vector 3 and I could say for the X I'm going to do my horizontal input from 57 00:04:04,710 --> 00:04:05,380 our y. 58 00:04:05,500 --> 00:04:10,170 Going to do my vertical input and then for my Z it's going to stay zero. 59 00:04:10,320 --> 00:04:17,640 From there I could multiply that vector by my speed multiplied by time delta time close it off with 60 00:04:17,640 --> 00:04:25,170 a semicolon at scoot back over here comment out these two lines and if I run this I now have one line 61 00:04:25,170 --> 00:04:31,420 of code that works with one vector three later in your experience with unity. 62 00:04:31,440 --> 00:04:39,410 There is a concept of object pooling as well as a concept of garbage collection that you'll come across 63 00:04:39,710 --> 00:04:45,830 in programming and one of the things you'll come to find is that using the new keyword is something 64 00:04:45,830 --> 00:04:48,490 that is not so optimal in performance. 65 00:04:48,530 --> 00:04:49,640 If done quite a bit. 66 00:04:50,330 --> 00:04:56,510 So in terms of optimization This is the more optimal route because we're using only one new vector 3 67 00:04:56,510 --> 00:05:02,820 vs. 2 vector 3s here so but it's just a minor optimization. 68 00:05:02,830 --> 00:05:05,340 And for this intercourse so we're focusing on. 69 00:05:05,380 --> 00:05:13,050 But you can see here that I can move around left and right up and down with just one line of code last 70 00:05:13,050 --> 00:05:18,330 but not least if I want to take it a step further I could clean up this line of code a tad bit further 71 00:05:18,420 --> 00:05:25,650 by creating a variable type vector 3 and calling it direction in that direction equals a new vector 72 00:05:25,650 --> 00:05:36,990 3 and I can specify a horizontal input a vertical input NZ for frizzy from there I could actually replace 73 00:05:36,990 --> 00:05:44,550 this entire new vector 3 line with my direction so my direction multiplied by speed times time delta 74 00:05:44,550 --> 00:05:45,170 time. 75 00:05:45,300 --> 00:05:51,150 This is also the exact same with the inline version I had before I just cleaned it up with a local variable 76 00:05:51,660 --> 00:05:57,420 so I have my orders onto inputs vertical inputs and then I'm calculating the direction of travel equal 77 00:05:57,420 --> 00:06:02,680 to a new vector 3 I pass in my user input and then I translate by that input. 78 00:06:02,790 --> 00:06:09,910 So here I can save this hop back into unity let it compile and when I run the game you'll see here that 79 00:06:09,910 --> 00:06:16,120 we can actually continue moving left and right up and down when I run the application and there you 80 00:06:16,120 --> 00:06:16,320 go 81 00:06:19,680 --> 00:06:23,150 so whichever way you want to do it is the correct way. 82 00:06:23,160 --> 00:06:27,240 What's important here is that you completed the challenge on your own and throughout the course I want 83 00:06:27,240 --> 00:06:29,820 you to continue completing challenges on your own. 84 00:06:29,910 --> 00:06:35,340 Do not watch the challenge reviews until you have figured it out on your own if you need to help contact 85 00:06:35,340 --> 00:06:41,220 me on game dev HQ dot com where we have an entire answers page and fifty thousand community members 86 00:06:41,310 --> 00:06:43,140 who are happy to help you out. 87 00:06:43,170 --> 00:06:44,430 I'll see you guys in the next video. 9540

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