How to load a scene after a timer or delay in Unity3D with SceneManager

Sdílet
Vložit
  • čas přidán 5. 08. 2024
  • Check out the Course: bit.ly/3i7lLtH
    -------
    Load any scene after a configurable delay with this easy script. Download the example project or work along with the video example.
    More Info: unity3d.college
    Download Link: unity3dcollege.blob.core.wind...

Komentáře • 94

  • @ElMatero6
    @ElMatero6 Před 2 lety +18

    5 Years later, and it still works flawlessly. Thank you good sir!

    • @BLUESCREENXD
      @BLUESCREENXD Před 8 měsíci

      6*

    • @ElMatero6
      @ElMatero6 Před 8 měsíci

      @@BLUESCREENXD I posted that a year ago. Learn to read

    • @BLUESCREENXD
      @BLUESCREENXD Před 8 měsíci

      @@ElMatero6 I know, it’s just a flavour of nostalgia

  • @brotnjanin
    @brotnjanin Před 4 lety +2

    Great video! I wasn't able to find any videos that go straight to the point of a countdown timer. Liked.

  • @annieabu
    @annieabu Před 6 lety +2

    Thank you! I've been trying to figure out how to do this for many hours and this helped me immensely!

  • @joaomede
    @joaomede Před 6 lety +1

    I came back here to enjoy your video and follow your channel, after a long marathon trying to create a splash screen with a video in .mp4, it was with his teaching that I was able to put together a code of mine and create it! Thank you so much from Brazil.

  • @vitrog4302
    @vitrog4302 Před rokem

    I had a doubt about that and you already had an answer 5 years ago. Thanks!

  • @dougdrexler7558
    @dougdrexler7558 Před 7 lety +1

    Brilliant, Jason! Direct and clear! Thank you!

  • @vivkali2325
    @vivkali2325 Před rokem

    This might be old, but this was a life saver! Thank you!

  • @sammy1122ttv
    @sammy1122ttv Před 4 lety

    Wow ur the first one from who my script worked. Thanks!

  • @denisgoodman4492
    @denisgoodman4492 Před 2 lety

    I was searching other thing, but found some nice features, which i didn't know before. Jason you are Great ... :) as always

  • @peterpenev02
    @peterpenev02 Před 2 lety

    Great work, despite the low views and likes, that's a well explained tutorial!

  • @Coder420
    @Coder420 Před 6 měsíci

    what a beautiful simple logic is possible to do, I am amazed and disappointed that I can't think like that yet, you re G

  • @hiabex
    @hiabex Před 2 lety

    Just letting you know that your tutorial has saved my ass from deadline doom. Thanks

  • @darkness2940
    @darkness2940 Před rokem +1

    You saved my life!! Thank you very much :D

  • @othmaneessayeh163
    @othmaneessayeh163 Před 5 lety +3

    you are saving me, thank you so much

  • @LeoPowa
    @LeoPowa Před 2 lety

    thank you very much,now my project works,time for transitions now

  • @FuriousCreeper
    @FuriousCreeper Před 4 lety +3

    Thanks man. I've made a Easter egg which it shows if you stay 2 mins on the menu screen. Very useful

  • @liam15068
    @liam15068 Před 3 lety

    It worked amazing thank you so much for the help!

  • @jackob937
    @jackob937 Před 3 lety

    Man You Saved My Game!!!!!, Thank You, I Can't express my words, you saved me bro you saved me!

  • @895games8
    @895games8 Před 4 lety

    thanks worked very well for a project I'm working on

  • @noobiestpro5172
    @noobiestpro5172 Před 2 lety

    THANK SOOO MUCH!! YOUR A LIFE SAVER

  • @iK1L73rV2
    @iK1L73rV2 Před 6 lety

    thank you very much this is just what i needed

  • @lukakoto
    @lukakoto Před 4 lety

    Thank you very much this helped me a lot!

  • @killaonmoco
    @killaonmoco Před 4 lety +7

    Again, can't say it enough, this is exactly what I needed, just as good if not on par with Brackey's.

    • @waterfallgames3620
      @waterfallgames3620 Před 3 lety +1

      We miss him already

    • @muminamir3755
      @muminamir3755 Před 3 lety +4

      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      using UnityEngine.SceneManagement;
      public class script : MonoBehaviour
      {
      [SerializeField]
      private float delayBeforeLoading = 10f;
      [SerializeField]
      private float timeElapsed;
      private void Update()
      {
      timeElapsed += Time.deltaTime;
      if (timeElapsed > delayBeforeLoading)
      {
      SceneManager.LoadScene(1);
      }
      }
      }

    • @muminamir3755
      @muminamir3755 Před 2 lety

      @Corsoul Studios np homie

  • @hannahkatart
    @hannahkatart Před 5 lety +1

    This saved me!!!!! Thank you so much!!!!!!!

  • @garypowell3566
    @garypowell3566 Před 5 lety

    Superb Tutorial, Thanks

  • @bhanu4923
    @bhanu4923 Před 2 lety

    Thanks sir, I tutorial saved my lots of time and problems

  • @farihaamin5773
    @farihaamin5773 Před 3 lety

    Thanks ...It was very useful

  • @leomagpoc9143
    @leomagpoc9143 Před 5 lety +2

    this worked great loading the first three scenes of my project, but when I added a fourth scene the timing became very inconsistent. I am pretty new to unity, does the timing get more inconsistent the more scenes you add, or how complex the scene is? Is there a way to keep the timing more consistent. otherwise it works great.

  • @fernando28nrp
    @fernando28nrp Před 2 lety

    thank you for this tutorial! I'm new at Unity, and trying to do this from scratch was a nightmare for me!

  • @lolo2k
    @lolo2k Před 6 lety

    Thank you!!!!!!!!!!! Subbed

  • @spynerexe4172
    @spynerexe4172 Před 5 lety +3

    can you help me?
    i want the player to be in a location where if you go idle for a long time,it will trigger a scene.
    For example:
    I am standing in a tall building for a long time and when the timer runs out,a scene will trigger where someone will push the player off the building causing a game over,but when the player isnt in that range where the scene will occur,the timer turns off automatically and turns back on when youre inside its range.
    if you cant understand what im saying im sorry...

  • @Alex-vu5uu
    @Alex-vu5uu Před 6 lety

    THANK YOU!

  • @jk8826
    @jk8826 Před 3 lety

    Thank you!!

  • @MrPino
    @MrPino Před 6 lety +1

    THANKS A LOTTTT!!!!!!!!!!!!!!!!!!!

  • @gregoryfenn1462
    @gregoryfenn1462 Před 5 lety

    I have a Q about the scope of attributes like [SerializeField]. : does the attribute apply to to whatever is the next field? Or would it apply to a property too? Also, if you used braces {} after an attribute, would you be able to make it apply to several fields at once, rather than needing to add the attribute over and over again?

  • @evokem1819
    @evokem1819 Před 4 lety

    Thankyou SO much

  • @diegodaly
    @diegodaly Před 5 lety

    Thanks!

  • @anthonycollins7992
    @anthonycollins7992 Před 5 lety

    Hi, i was using this for one of my "onclick" buttons. It works perfect, but the only problem is it's triggering on all my buttons though it's not attached to them. Any idea what could be causing this?

  • @MarianaRamacciotti
    @MarianaRamacciotti Před 6 lety

    thank u! :D

  • @sirenjoy1
    @sirenjoy1 Před 4 lety

    Thank's a lot

  • @foxycoffee6054
    @foxycoffee6054 Před 4 lety

    Thx Dude :)

  • @sreeni333
    @sreeni333 Před 6 lety

    Thanks for video

  • @vini8v8
    @vini8v8 Před 4 lety +1

    I want to buy you a coffee hahaha
    Thanks ♥

  • @Killer_Nads
    @Killer_Nads Před 7 lety

    Another brilliant video, thanks so much.

  • @siscoye9454
    @siscoye9454 Před 5 lety

    what are the buttons for Ctrl+. (period)

  • @RushlineCode
    @RushlineCode Před 2 lety

    can i use it for wait for second before attacking the target?

  • @metaversohoy8230
    @metaversohoy8230 Před rokem

    I extracted my assets to bring it into the new project so i can upload to Spatial and I can bring them in with no problem but when I try to load my scene so i can see my project unity crashes. Any help would be apreciated.

  • @jonasvflores
    @jonasvflores Před 5 lety

    THANK YOUUUUUUUUUUUUUU

  • @ghazi707
    @ghazi707 Před 3 lety

    thankyou

  • @mcphillipramon7591
    @mcphillipramon7591 Před 2 lety

    Hello i got a question, the 10 that ge put, is that a seconds or minutes?

  • @dunderguy
    @dunderguy Před rokem

    I know I'm 5 years too late on this video but I basically have this working but I just have one question. Basically I have this to where if you walk into a trigger, then wait 5 seconds, you die. I want the player to be able to escape the death part and if they were to step out of the trigger, the script would deactivate. Do you have any idea how I could do this? I'm kind of new to Unity.

  • @SerdSoftInteractive
    @SerdSoftInteractive Před 4 lety +10

    0:08 OMG

  • @GurmeetSingh-ur9qv
    @GurmeetSingh-ur9qv Před 3 lety

    we can also use invoke method to call a method after certain time rather than calculating time with delta time

  • @foxzyx
    @foxzyx Před 3 lety

    Is there a way I can do this but start the delay after I press a button

  • @serenatadros3315
    @serenatadros3315 Před 6 lety +1

    Is there any way to add a fade out/in before the scene reloads ?

  • @yurioliveiraa_
    @yurioliveiraa_ Před 5 lety

    ty

  • @matstacy6830
    @matstacy6830 Před 4 lety +1

    thankyou for the video. but is there anyway i can have the timer only start after a button is clicked

  • @antonios8520
    @antonios8520 Před 6 lety

    is there a way to set this to load a random scene from a list of 4 different ones?

    • @Unity3dCollege
      @Unity3dCollege  Před 6 lety +1

      Sure. You'd want to put the scenes in an array, then use UnityEngine.Random.Range(0,3) to pick a random index between 0-3 (assuming four scenes). Then just load the scene at that index. LMK if that doesn't make sense

  • @raef404
    @raef404 Před 10 měsíci

    So scene 0 can be used as background music loader and dont destroy onload then to auto move menu scene (1).
    There should be no duplicate issue if you move between game levels and menu.

  • @rodmanunderhilliii8198

    Hello, even though I knew the method on how to get to the next scene, I liked how you explained, other things connected to what your where instructing us on. I have been searching for a tutorial on how to set the landing transform position, for the player. I found one for 2d but it also involved scriptable objects, and I was hoping to be able to determine where my player lands, after a scene change. I would like request you make such a tutorial, which I perceive many will enjoy.

  • @studyxtraacademy6994
    @studyxtraacademy6994 Před 6 lety

    Hi.Please help,how can i When image target is detected, trigger a new scene

    • @gregoryfenn1462
      @gregoryfenn1462 Před 5 lety

      Mxolisi Khumalo I don’t think any of us know what you mean.. do you just want to load new scenes whoever the player moves their cursor on top of a certain image? Just send a camera raycast and detect the image layer or tag or something, and use that data to trigger an event or call the SceneManager class then and there

  • @pnvgordinho
    @pnvgordinho Před 2 lety

    HI. I tied your code and it works but Im having an issue. I have a fade out animation and it seems that when the time goes out, it changes scene and doesn't play the animation. How can I fix this?.
    Thanks for the tutorial.

    • @shadedgecko2302
      @shadedgecko2302 Před 2 lety +1

      maybe make a delay for the animation and then depending on how long it is add more delay so it moves to the new scene after your animation

  •  Před 4 lety

    Thanks +1Sub

  • @boratthe
    @boratthe Před 3 lety

    This script still works in 2020 , it’s better to write the script when he’s done writing, so you don’t have to do the fixes and stuff

  • @kevindebruyne144
    @kevindebruyne144 Před 6 lety +2

    can you delay a load scene after a collision to show off an explosion? if so can someone please provide me with a script

    • @brainovergames7790
      @brainovergames7790 Před 5 lety +1

      Simply, do it with bool. For example:
      bool startTimer=false;
      void OnCollisionEnter2D (Collision2D col)
      {
      if (col.gameObject.name == "gameObject name that has collider here")
      {
      startTimer=true;
      }
      }
      //NOW, YOU CAN USE THIS BOOL STATE(TRUE/FALSE) IN UPDATE FUNCTION
      void Update()
      {
      if(startTimer==true)
      {
      timeElapsed+=Time.deltaTime;
      if(timeElapsed>10f)
      {
      SceneManager.LoadScene(1);
      }
      }
      }

    • @harrywood3698
      @harrywood3698 Před 5 lety

      Hi, I know im late but the best way to fix that is by enabling the game object your LoadAfterScript is on after a collision. Hope that helps.

    • @alipk2633
      @alipk2633 Před 5 lety +1

      @@brainovergames7790 you are a genius
      thx alot for the info and the code

  • @swordsdragon
    @swordsdragon Před 4 lety

    How do I script a scene change based on a killCount?

  • @angelica7692
    @angelica7692 Před 2 lety +3

    using UnityEngine;
    using UnityEngine.SceneManagement;
    public class LoadLevelAfterTime : MonoBehaviour
    {
    [SerializeField]
    private float delayBeforeLoading = 10f;
    [SerializeField]
    private string sceneNameToLoad;
    private float timeElapsed;
    private void Update()
    {
    timeElapsed += Time.deltaTime;
    if (timeElapsed > delayBeforeLoading)
    {
    SceneManager.LoadScene(sceneNameToLoad);
    }
    }
    }

  • @souhdje5827
    @souhdje5827 Před 3 lety

    THX but its not relly what i wont

  • @francescobrunocia3110
    @francescobrunocia3110 Před 2 lety

    hours wasted cz i wasn't using +=

  • @zaarbeats
    @zaarbeats Před 2 měsíci

    Thanks!!! 🙏🙏🙏🙏

  • @myimr1512101
    @myimr1512101 Před 6 lety +11

    using UnityEngine;
    using UnityEngine.SceneManagement;
    public class LoadLevelAfterTime : MonoBehaviour
    {
    [SerializeField]
    private float delayBeforeLoading = 10f;
    [SerializeField]
    private string sceneNameToLoad;
    private float timeElaspsed;
    private void Update ()
    {
    timeElaspsed += Time.deltaTime;
    if (timeElaspsed > delayBeforeLoading)
    {
    SceneManager.LoadScene (sceneNameToLoad);
    }
    }
    }