#UnityTutorial #SimpleUnityGame #unitytimer #unitycountdowntimer
The BEST MECHANICAL KEYBOARD Metoo Zero for the price. I use it. And I must say that it’s perfect!
Consider purchasing my ULTIMATE UDEMY COURSE with great discount
In this video I will show you how to create a simple linear timer for your Unity game.
First I add a funny surprised face so our scene doesn’t look so empty. Next I create a new UI text game object and name it Time’s Up text. It’s kind of game over sign. Change its text field. Position it at the center of the Canvas holding Alt+Shift keys. Set alignment. Change font size. Set overflow so the text becomes visible. Change its style and color.
Next right click on Canvas and create new UI image. Drag and drop linear timer sprite to Source Image slot. Check Preserve Aspect option. Anchor it to the top center holding Shift key. Change its width and lower it a bit. I rename it to linear timer.
Now change its Image Type to Filled and set Fill Method as Horizontal.
We are going to change its fill amount through the script so let’s create new C# script named TimerScript.
In this script we use UnityEngine.UI library to have an access to UI elements. Here we have Image timeBar gameobject, public float maxTime variable which we are able to adjust in inspector, float timeLeft variable and a reference to timesUp text game object.
In Start() method we disable timesUpText game object, get timerBar game object and set timeLeft variable.
in Update() method if statement goes. So if timeLeft more than zero then we decrease its value by deltaTime and set fill amount of the timerBar to timeLeft devided by maxTime. And if timeLeft less than zero then we enable timesUp sign and set timeScale to 0 because the game is over.
Put this script to LinearTimer game object. Select Linear Timer and drag and drop Time’s Up text to corresponding slot of Timer Script component.
Hit play and see how it works.
You can support me through
www.patreon.com/alexanderzotov
or here
Thank you)
www.vecteezy.com – best free vector graphics library ever!
What this video is about and what it can be used for also: unity 2d tutorial,
unity tutorial, How to create a linear timer for your Unity game, linear timer unity, countdown timer unity, timer unity, time’s up unity, game over unity, time is over unity, how to create timer unity, add timer unity game, game over timer unity, game over countdown reaches zero unity, game over time over unity, time left unity, game over time unity, time unity, learn unity fast, unity tutorial, how to make games with unity, unity how to make game, unity how to make 2d game, not as good as brackeys but good as well.
Nguồn: https://twentyfiveautumn.com/
Xem thêm bài viết khác: https://twentyfiveautumn.com/game/
what if reverse? instead of deleting, it is showing image ?
Great tutorial! It was super helpful! Thank youu!
Great tutorial but I want the slider start countdown when ever I set active a obejct
dat reggae tho!
btw, how to get the linaer time of that image
Hey Alexander, another great tutorial and Thank you! I am having trouble making the bar fill up instead of going down… i tried :
timeLeft += Time.deltaTime;
timerBar.fillAmount = timeLeft – maxTime;
and it worked to fill up but just goes same speed no matter what i set maxTime to.
what is the correct math for this to fill up?
man i need this really much !!! thanks !!
can i have the script please?
Thank you soo much 😍
thanks
Русский?
which music at the back
Where do i download the timer
hay I have tried to apply it to every scene, but why when the timer reloads it doesn't work, can you help me?
Thank you helped Me:-)
You sir, are a legend. Many thanks for this video!!
really useful tutorial tysm <3
it works perfectly but when I restart the game it wont work anymore please help me 🙂 thanks..
short tutorial, simple as can be, and i understand more then in any other tutorial…
thank you very much zotov you're the best
Hi I have a doubt my character in unity is falling through the terrain what to do
Awesome video. I have one question, can you show/describe for me how you got Linear timer and after that, you took linear timer into source image. Because I watched your video multiple times and I couldn't get it.
Great video. However, I have a question. How can I get linear Timer because I tried multiple times and I couldn't get it.
Keep up the good work.
Thank you very much… 🙂
Very simple and effective video superlike 🔥
U are great!Thanks Mate!!!
Thanks a lot for a simple and easy tutorial
Thanks for tutorial…