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
Now we want to add some kind of a game mechanic to this, so game mechanics are almost like the rules
or the gameplay element that makes it addictive and makes it kind of fun and interactive.
And in this one where we're going to add a timer, so you get maybe 30 seconds and you have to survive
for 30 seconds against an endless loop of enemies.
And if you manage to make it to 30 seconds, then it will load the next level.
OK, and the whole idea behind this game is you've got to see how many levels you can achieve.
It's almost like Tetris.
You know, in Tetris, it keeps getting faster and faster and faster each level you go up.
So you just see how long you can survive.
Now, that's kind of the idea that I want to put into this game.
So, first of all, we need some kind of text at the top, and this is going to be on that canvas.
So I'm going to right click UI.
And that some text now probably be somewhere in the center of the screen and really odd to see.
So I'm just going to change the color to white.
And I'm going to change the size to maybe about 80.
And then I'm just going to move this up.
There it is.
Just click and drag on the Y.
And then I'm going to click on the alignment center so I can get it centered on the screen.
And this is just goodness.
Let's say that we give around 30 seconds.
Yeah, my font style might actually make that bold, just so it stands out a little bit more.
OK.
And we're going to be controlling this text through code.
So I'll just rename this time of text.
So now in our script, in the main script, we're going to
leave ourselves and a comment, so I'll call a timer.
And first of all, we need a public offsite text or call timer, then a public integer.
I'm going to call level time limit.
And to make that equal, about 30 and then a private integer we'll call level current time.
Keep, keep, keep a record of exactly how many seconds have passed by.
And now this is one of the reasons why we've got this time countdown.
Instead of doing this every frame, we know that we only want the time to go down each and every second.
So we're using a one second coroutine or a one second pulse that avoids overloading our update method
and with unnecessary commands.
OK, so we can use our time countdown where we have time.
Countdown to his start in the coroutine time delay.
OK, well, we actually want to make sure that only happens as long as time is greater than zero.
So we can say if the level of time is greater than zero.
And run this custom function.
OK.
However, we do also need to ensure that we're taking time off.
Current time.
So we're going to stay level current time minus equals one each time this runs, and this runs once
per second.
And then we also need to update our text as well.
So I'm going to say timer.
So text lowercase equals level current time.
OK.
And if I leave it at that.
Notice that I get this red squiggle.
So you cannot implicitly convert time integer to string.
All right.
String this basically just text.
So we do dot to string.
And that will then convert it, OK, into an into actual text.
Now we need to essentially say if.
Level current time
is less than or equal to zero.
Not not case for now.
We're just going to pause the game to make sure it works.
So when you say time, double time scale.
Equals zero.
OK, and that will effectively just pause the game.
So let's save this.
Wait for that to compile.
And then, you know, our main script, we should now have a time, a text, let's drag in that time
a text.
There we go.
And we know that we're running on about 30.
So let's just try this and make sure that that time is actually going down.
OK.
And now and at the moment, it pulls the game for some reason.
Let me see if Lovel caught on tape.
OK, what is.
Second, wait a second.
Yeah, I need to make in the start.
I need to make my level current time equal my level time limit.
That's what I've not done.
Level current time start to zero.
OK.
So in the stop and say level, current time equals level time limits.
There we go.
So that will pass that throw through to that current time.
Now, if you wanted, for example, to 60 or 90 or whatever you want, you can do so in the ed, and
it will automatically pass it through to the level Covid time.
So save that and then let's try it again.
Well, we know it just pulls the game zero.
So that's good.
OK, instantly, there we go, and time is now going down each and every second.
OK, excellent.
And so what we'll do in the next video is we'll set it up so that when it reaches zero and it can actually
load the next level.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.