Unity 5 - Changing Scenes when Timer Ends

preview_player
Показать описание
A simple way of making a good looking timer in unity which changes scenes when it reaches 0.

All scripts & assets:
Рекомендации по теме
Комментарии
Автор

Thank you so much for the simple and easy tutorial, it worked for me and it didn't even take me 3 minutes to accomplish the result that i was looking for. Keep up the great work.

joubaghloubagh
Автор

works like a charge nearly 70% of my missions in my games are based of your scripts. so helpful.

Zukomazi
Автор

Wow thanks a lot man, been searching for how to load a scene after a certain amount of time and every solutions I found was too complicated for my taste, yours is short and sweet!

joel.s
Автор

using UnityEngine;
using System.Collections;
using UnityEngine.UI;


public class Timer : MonoBehaviour
{
public string LevelToLoad;
private float timer = 10f;
private Text timerSeconds;


// Use this for initialization
void Start()
{
timerSeconds = GetComponent<Text>();
}

// Update is called once per frame
void Update()
{
timer -= Time.deltaTime;
timerSeconds.text = timer.ToString("f2");
if (timer <= 0)
{

}

}
}

TheSDestinyS
Автор

Thank you! Great video and so useful for my project.

melissasandison
Автор

Thank you very much I've been looking for so long!😀

surgal
Автор

here is the script... cause its not on his gihub :/



using UnityEngine;
using System.Collections;

public class Timer : MonoBehaviour {
public string LevelToLoad;
private float timer = 10f;
private Texture timerSeconds;


// Use this for initialization
void Start ()
{
timerSeconds = GetComponent<Texture> ();
}

// Update is called once per frame
void Update ()
{
timer -= Time.deltaTime;
timerSeconds.text = timer.ToString("f0");
if (timer <= 0)
{
Application.LoadLevel (LevelToLoad);
}

}
}

thecubikle
Автор

much needed video gonna try this out thanks

brucewayne
Автор

Thank you for this tutorial it really helped!!

hannahcassidy
Автор

incredibly awesome! Thanks a lot bro is very useful

unessoum
Автор

Only viedio I found with auto timer transition... Thankyou!!!

bhanu
Автор

Thanks for the tutorial it help alot :)

raniaoues
Автор

Thank you very much lurony !
it is really helpful
incredibly awesome!

mahmoudshatnawi
Автор

hey! is it normal, that I get a lots of errors, during the timer is working and when it stops, I don't get any errors anymore? this is the error:
NullReferenceException: Object reference not set to an instance of an object
Timer.Update () (at Assets/Scripts/Timer.cs:23)

i

maries
Автор

thanks this helps soooo much... just had to tweak the script a little bit

thecubikle
Автор

how to stop timer counting after player`s death?

tpfweus
Автор

Assets/scripts/Timer1.cs(8, 9): error CS0246: The type or namespace name `Text' could not be found. Are you missing `UnityEngine.UI' using directive?

Alex-vuuu
Автор

Can you help me make a thing where i can set up a script where an npc would do something if you go into his fov with a weapon within 1 second, and not if u have like an id card/disguise?

SierraDyne_
Автор

Thanks this put me on the right track since the update this is obsolete and SceneManger.LoadScene should be used. My code looks like this:
public void changeSceneTo(int changeMyScene){
SceneManger.LoadScene();
}

In my update method

If time up...

changeMyScene (int that relates to the scene);


You can find the int by looking in the build settings and 'Add Open Scenes'. Hope this helps.

redghost
Автор

what is written after timer in the void update function?

jaymehta