Afrikaans
Akan
Albanian
Amharic
Arabic
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
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
So whenever you wanted to move this player in various
Directions maybe to left or to the right
What do we do that is actually with something called variables
Variables are declared or another way of putting it is there born or birth
Before the start of function
So let's come up with a variable called speed
Private
Float
Speed
Closet
Basically what we've done here is we've spoken into existence
A new variable and that variable is a float
Godspeed
You don't know the floor is that's ok I didn't know what a flow was either when I started scripting a flow is basically a decimal number
Integers which is 12345 and someone in this float switch is 1.2
Subtitled by -♪ online-courses.club ♪- We compress knowledge for you! https://t.me/joinchat/ailxpXoW3JVjYzQ1
554 2.33
You want to use floats for Speed because it's slowly going to maybe Accelerate from €100 to
So
Speed could technically be 5.654 or we can make this
That's a 1 point
34567
So that is our float for Speed
Don't worry about this word private will talk about private and public in just 2
First I want to talk about why you would use a variable
Change this five
Actually speed
So what is Speedwell speed is 1.3 4 5 6 7
So that means that are transformed position is going to move at the rate of 1
34567
Tell if we save
Going the Unity
Play
You see the speed is now moving at that rate
The reason you're gonna use variables because you want to be able to reuse them when you can or change them at
10 time
Self example what if in the start I said well actually want my speed to be
5.55
4
Now
Because this function is going to fire first
Once we hit the update function speed is now going to be equal to this
Save it down hip play
This is moving like faster
What are the cool things about variables that you can actually change them in the universe editor you actually have to write them
In a script to change them
Instead of doing that
Delete that
And we can actually do something called serialising a field so we can do serialise field
All that means is there any inspector now
You'll see the variable speed
Right here
Technically changed this year
2.01
It's going to override
What we declared here
That's cool because we have an enemy script
Using it multiple times across maybe doesn't have enemies
Maybe some enemies you want to move in a different way
Go ahead play
Moving very slowly can almost
Barely see it
And to change that variable at runtime
Where we go or what about going backwards
Here we go so that's the benefit of variables especially when they see realised
Now we can do is actually happy if we wanted to he copy this player
Multiple times
Chelsea unit control
How many could set each wind have different speeds of 1
5
-2
And then hit way
And so now I cannot take enemies patrolling
Through the scene
That's the benefit of having serialised Fields
My inspector here
That's a float
Does other kinds of variables as well
Is also bullying
Private bullion
Dead
A bullying is basically true or false
I'm like a float
True or false is either basically 1 or 0 and can be anything else one being true
False
Even what use the words true or false
Dead is going to be true or false
By default can be false
So would want to start a live so we're not dead which is private
And this would be health help would be an integer you either
10 9876543210
That's a good use of an integer help
Now you should be something like a coin there's you can't really have
3.5 pennies
In real life
You can either have three or four so that's the use of an integer
There's also
Strings
So I say what's my name
Well we could are call herself Billy
That is a string
The reason why there's a green zig zag line is because there's actually variables called name already
Inside of a monobehaviour
So we really don't want to use that cos I can get a little bit
So what we do player name
Here we go
Universe all of my variables are lowercase
All variables should be lowercase
Without spaces
You can use underscores if you like
But I tend to just you lowercase and then anytime is a new word
Abaqus scripting classes on the other hand or uppercase
In functions are uppercase as well
Definitely want to follow this rule especially going to be working with the team and just
Funny I'm working on a game long term
Switch it on for crazy and don't pick your team members go crazy
To keep your variables lowercase with uppercase anytime you have a new word in that variable
An app that starting a new function
Or
Naming a scrim
So again if we save these out you never said nothing is actually showing up in the inspector
Because remember
We need abuse the serializefield
Actually show them
Indeed inspector
Search back in inspector
Can you see they're all here
Set Dead true everyone
The more we play
We have the health set to 10
Maybe for some players
I characters we can do the health and safety and maybe his name is
Jack
And
Sammy
With the help of 25
Now let's talk about what private means
A private variable is basically something that only going to be accessed by this script
What about a script called enemy
Well if enemy wanted to let say
Set Dead to false
Or Set Dead 2 true for the player I couldn't actually do it
Because it said the private
This variable dead in this very bad health and the name the speed only
This class can adjust these variables
Apollo variable
Actually means that any script
Any script inside of Unity
Whether the enemy script or a weapon script or a bullet straight or anything
Access this variable in change it
No call thing about public variables if you don't actually need to serialise them because hey the public say
Even unity the editor is going to have access to that
So even though we don't have serialise written here before the speed variable
United States still there
But the moment we make it private
Disappear
Basically
Every variable by default should always be private you should only said at the pub
If you know for certain that you need to access that variable
From a different script we're going to be creating an entire prototype and we're going to using private and public variables
Don't worry if this doesn't make sense just yet
So getting the recap we have floats which are decimal numbers speed is a good way of using a float
We all have brilliant which are true and false
Remembering integer is single number 01234 basically digits
And then finally strings which are actual names and they always appear inside
Quote
And then a word
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.