All language subtitles for 9. Challenge User Input

af Afrikaans
ak Akan
sq Albanian
am Amharic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
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
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
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 Spanish
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
tr Turkish
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

Original subtitles

In this video we're going to take a look at using the input manager of unity to map our user inputs

to our character.

For example I want to be able to move left and right based on the Andes Keys and up and down based on

my W.S. keys in order to do this we need to take a look at the input manager to check out the input

MANAGER We're going to go to edit project settings and you'll see here that there is something called

input and within the input we have what's called accesses unity by default provides us with 18 different

accesses that we can use to map user input and you can add your own.

For example you'll see there's things here that are jump in fire which are already mapped to things

like game controllers and the spacebar.

What we're interested here is the horizontal and vertical axis is if I check out the horizontal axis

here you'll see here that it has a negative button as well as a positive button and it's the left arrow

in the right arrow.

It also has an alternate negative button and positive button which is map to the HD keys.

So what I want to do is I want to use this access to move horizontally.

The next thing you'll notice here is that it has a name.

I'm accessing the horizontal axis and by doing that I can use a and d.

But what needs to make sense to me is how how do I use this to move my character with a D.

Well it comes down to what do I get.

What is this value.

If I were to do anything with this horizontal axis what does it mean.

So let's check out what's being returned here.

What are the things that the axis is.

Don't really tell you is what they return buttons are Easy buttons are boolean they're true or false

if you hit a button but what about a horizontal and vertical axis that determines if you're hitting

an HD key to move an object.

Well this is where it comes down to.

We need to store it in a variable in viewing what I'm going to do here for testing purposes and you

don't have to follow along with this but if you'd like to you can.

I'm going to create a public float variable of type horizontal or not have type just the name horizontal

I'm just you can name it whatever you want but here we have public float horizontal and let's call it

horizontal input.

The reason why it's a float is because I know that that horizontal input is going to return a float

value.

And what I want to do is I want to say the horizontal input variable is equal to the input manager which

is the input and then what was the hierarchal step to get to that access.

Well we go to input accesses and then we specify the access we want I want the horizontal axis encode.

You say input get access and then you open a parentheses and then we can pass in a string of the axis

name anytime we're working with strings you're gonna use quotation marks and we're gonna type in here

the horizontal axis if we save this and hop back into unity I'm going to close the input manager and

run the game and watch what values appear next to this horizontal input in the inspector you'll see

here that our character is not going to be controlled but if I hold down the left arrow it goes from

zero to negative 1 if I hold down the right arrow it goes from zero to positive 1.

Likewise if I hold down the 8 key or a negative on the D key is 1 if I'm not holding any keys the horizontal

input value is 0 using that knowledge we can use this horizontal input variable and the way we can use

this is I can basically I don't need to necessarily see it so I'm going to remove it from there and

I'm going to create a local variable that's only used inside of update and it's going to be of type

floats and it's going to be a horizontal input equals input I get access horizontal once I've declared

that variable I'm going to move this to the top

and then in our transformed not translate method I'm gonna say vector three dot right multiplied by

our horizontal input multiplied by the speed multiplied by real time.

And if I save this and we go back into unity like Unity compile and let's run the application I can

now move using my d key to go write a key to go left right arrow key to go right and left Cherokee to

go left and if I stop moving I stopped moving.

Now let's take a look at how that works right now we declared our horizontal input using what's called

a local variable of type float and we just set it to the input dock get access horizontal inside here

I included the multiplication for that.

So now we have vector 3 about right which is new vector 3 1 you know on the right multiplied by horizontal

input which is let's say 0 when I start out multiplied by our speed which is three point five f mortified

by real time if I'm not moving what's my vector if I'm not moving 1 times three point five becomes I'm

sorry if I'm not moving one times zero is zero zero times three point five is zero and zero times real

time is still zero.

So we're not moving the vector length is zero.

Now what happens if I hit the D key or the right arrow key horizontal input becomes one new vector three

one times one is positive one one times three point five becomes three point five and then three point

five times real time is meters per second I now move to the right three point five meters per second

likewise what happens if I hold down the eight key or the left Cherokee this becomes a negative one

and if we look at the math here we have vector three about right which is one times a negative one which

becomes negative one.

So now we're moving to the left negative one times three point five becomes negative three point five

and then Z for the rest.

So that's how the math is working underneath so as a challenge what I'd like you to do is figure out

how to move vertically we're currently moving left and right like this go ahead and add the second access

which is the vertical axis and go ahead and move up and down.

I'll see you in the Challenger view.

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