Afrikaans
Akan
Albanian
Amharic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
And this challenge review we're gonna take a look at how to hook up the vertical input the way we could
do this is we need to create a variable that's going to store the vertical input.
So we'll create another variable of type float and we'll call this vertical input from here.
We're going to assign it to the input manager if I type input dot get access and then vertical this
name has to match exactly what is inside the project settings.
So if I check in and go to edit project settings
and then go to input you'll see here that the vertical access is called vertical with a capital V that's
going to return a float value based on zero and negative 1 or negative on the positive one.
Now that I have that vertical input I can begin re typing out a new transform translate line.
A common mistake with new developers is that they copy and paste code.
Stop copying and pasting code if you copy and paste code at an early stage you are setting yourself
up for failure.
Programming is a skill that takes practice and over time you'll become very experienced if you write
out your code.
Oftentimes we will see people do in this challenge is to go ahead and just copy this line paste it and
they will swap out the horizontal input with the vertical input.
However it didn't work and they'll ask me why.
Well I have one thing to say to them and every time they say yeah did you copy and paste it.
And if you hadn't done that you'd recognize that you shouldn't have added vector through dot right.
You could have avoided that had you just typed out the code and started correctly.
I always recommend you type out your code never copy and paste anything you see.
Always write it out.
Try to understand it with practice and experience.
You will get better and become a great software engineer so to do this I'm going to type out transform
not translate open my parentheses in the vector 3 translation instead of going left and right.
I want to go up and down.
So I'm going to say vector three dot up multiplied by my vertical input multiplied by the speed and
then I'm going to incorporate it all with real time.
If I save this and hop back into unity like Unity compile will run this and I can now move up down left
and right using the arrow keys as well as the WSJ keys.
You'll see here if I run unity we can now move left and right up and down.
We've successfully created user input movement.
Now you may be wondering is there a way to optimize this.
And is this the best approach.
And that's the beautiful thing about programming.
There is always more than one way to solve a problem.
And throughout this course you're going to come through several challenges that are going to challenge
you to come up with your own unique implementation of things.
And what I want you to do throughout this entire course is use your implementation.
Don't copy and paste what I type.
I want you to use your code.
Everyone who goes through this course should have a unique code base that's unique to them.
To truly become a great software engineer you need to go through trial and error.
You need to experience things in programming.
There is no wrong or right way to do things.
There are more optimal ways but there is never a wrong way to do things.
And again there is always always more than one way to solve a problem.
If I wanted to convert this into one line I could absolutely do that.
I'm controlling the x axis here.
The y axis here I could just put it into a new vector 3.
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
implementation you have.
You can keep this or you can go along with the more optimized way but I encourage you to keep what you
have but what we could have done is I could have said transform not translate.
And then here it's asking for a vector 3.
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
our y.
Going to do my vertical input and then for my Z it's going to stay zero.
From there I could multiply that vector by my speed multiplied by time delta time close it off with
a semicolon at scoot back over here comment out these two lines and if I run this I now have one line
of code that works with one vector three later in your experience with unity.
There is a concept of object pooling as well as a concept of garbage collection that you'll come across
in programming and one of the things you'll come to find is that using the new keyword is something
that is not so optimal in performance.
If done quite a bit.
So in terms of optimization This is the more optimal route because we're using only one new vector 3
vs. 2 vector 3s here so but it's just a minor optimization.
And for this intercourse so we're focusing on.
But you can see here that I can move around left and right up and down with just one line of code last
but not least if I want to take it a step further I could clean up this line of code a tad bit further
by creating a variable type vector 3 and calling it direction in that direction equals a new vector
3 and I can specify a horizontal input a vertical input NZ for frizzy from there I could actually replace
this entire new vector 3 line with my direction so my direction multiplied by speed times time delta
time.
This is also the exact same with the inline version I had before I just cleaned it up with a local variable
so I have my orders onto inputs vertical inputs and then I'm calculating the direction of travel equal
to a new vector 3 I pass in my user input and then I translate by that input.
So here I can save this hop back into unity let it compile and when I run the game you'll see here that
we can actually continue moving left and right up and down when I run the application and there you
go
so whichever way you want to do it is the correct way.
What's important here is that you completed the challenge on your own and throughout the course I want
you to continue completing challenges on your own.
Do not watch the challenge reviews until you have figured it out on your own if you need to help contact
me on game dev HQ dot com where we have an entire answers page and fifty thousand community members
who are happy to help you out.
I'll see you guys in the next video.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.