Background Loading & Loading Screens | Godot 4

Поделиться
HTML-код
  • Опубликовано: 28 окт 2024

Комментарии • 121

  • @albiceleste101
    @albiceleste101 Год назад +40

    The aesthetics and color scheme are gorgeous

  • @deadrats6781
    @deadrats6781 Год назад +37

    Great tutorial. Thank you. I only wish example code were a bit bigger. :) Specially when on second part of the screen is just 0% most of the time

    • @JumboGamedev
      @JumboGamedev  Год назад +7

      Thank you for the feedback, much appreciated!
      I will try to do better for future tutorials : )

  • @FPLogistic
    @FPLogistic 8 месяцев назад +8

    Quick and short, well edited, has all the info I needed to know. Just perfect! Thank you so much and I hope you can upload more often because your videos are really amazing

    • @JumboGamedev
      @JumboGamedev  8 месяцев назад +1

      Thank you very much! I am planning to upload more.

  • @mjdevlog
    @mjdevlog 26 дней назад

    The visuals in this channel is so good it's underrated!

  • @tigwykplaysgames
    @tigwykplaysgames Месяц назад

    Love how you manage to show off an entire concept in less than 3 minutes. I had no idea how to handle this before watching and now I have a path forward, thanks!

  • @sergeantsapient
    @sergeantsapient 4 месяца назад +3

    This was very useful and packed with a lot of info in under 3 minutes.

  • @evethedwarf
    @evethedwarf 11 месяцев назад +7

    Short and to the point. Love it and subscribed! :)

  • @Joao-bq4ys
    @Joao-bq4ys 27 дней назад

    My head exploded! Your concise explanations about several important Godot contents are very good!

  • @Speed-TV
    @Speed-TV 9 месяцев назад +2

    Thank you so much! I'm so glad to finally be able to have loading screens, I'm definitely saving this code!

  • @bitbraindev
    @bitbraindev Год назад +4

    Extremely useful. I will definitely add this to my game, too.

  • @Aratonati
    @Aratonati 8 месяцев назад +1

    Thanks so much! I was wondering how loading would work.

  • @darksoulcreeper7954
    @darksoulcreeper7954 3 месяца назад

    This tutorial is genuinely one of the best if not the best I've ever experienced. Yeah the code viewport should have been larger. But Very nice.

  •  5 месяцев назад

    Found one of your videos yesterday and have started to binge watch your channel. I like your aesthetic very much, and the short explanatory video format is very good for when you need fast instructions.

  • @AJMarraffa
    @AJMarraffa 5 месяцев назад

    Thank you so much, I was really confused on how to get this process started. My code was close but wasn't working, this helped me adjust it so it worked :)

  • @ProrokLebioda
    @ProrokLebioda 6 месяцев назад

    Clean, quick, concise! Great video! Just the short tip I needed to add loading screen! One for pause menu was useful as well!

  • @gamingxrelic
    @gamingxrelic Год назад +2

    Such an outstandingly made video. Great job and thank you for explaining it so clearly!

  • @ClutchMonkey
    @ClutchMonkey 3 месяца назад

    The most efficient tutorial I have ever watched. Subscribed and Bell on.

    • @JumboGamedev
      @JumboGamedev  3 месяца назад

      Thank you, much appreciated!

  • @ThatSommeS
    @ThatSommeS Год назад +2

    Thank you! Great tutorial with a very clear and accurate delivery

  • @kyuos
    @kyuos 5 месяцев назад

    One of the Best explainations how it works. Keept it up!

  • @kiryonnakira7566
    @kiryonnakira7566 4 месяца назад

    short, clear, and clean. Thanks man

  • @gouldghost
    @gouldghost 3 месяца назад

    So simple, worked first try. Thank you!

  • @psycho_ocelot
    @psycho_ocelot 5 месяцев назад

    The video is very useful and your video editing is very good. Keep up the good work.

  • @meraklmuskulpesent8313
    @meraklmuskulpesent8313 Год назад +3

    Great tutorial. Keep up the good work.

  • @TheRealAfroRick
    @TheRealAfroRick 11 месяцев назад

    Very clearly explained. Gonna wrap this into some UI components for my game this afternoon.

  • @tejaswithme3713
    @tejaswithme3713 6 месяцев назад

    Great tutorial brother!
    Love from India ❤

  • @DemKartal
    @DemKartal 11 месяцев назад +4

    In this example you are using get_tree().change_scene_to_packed(newScene) which automatically unloads every other scene. Is there a way to make it work with get_tree().root.add_child(newScene)? (That one throws an error, saying it cannot handle a PackedScene. Consider "sceneName" holding a path like in your example.)
    In my case it is not desirable to have everything unloaded... or is it a better approach to push everything which is supposed to be available (almost) permanently into global/autoload?

    • @DemKartal
      @DemKartal 11 месяцев назад +5

      I think I figured it out:
      loaded_scene = ResourceLoader.load_threaded_get(saved_path)
      var scene = loaded_scene.instantiate()
      get_tree().root.add_child(scene)
      Please correct me if I am wrong!

    • @JumboGamedev
      @JumboGamedev  11 месяцев назад +4

      ​@@DemKartal You are absolutely correct!
      - A packedScene is an object that represents a scene. We can think of it as an object that contains all the information needed to instantiate/duplicate the nodes in this scene. So a packedScene is like a tree template, and we can invoke instantiate() to clone this structure.
      - When we invoke the instantiate() method on a packedScene, we get a new scene instance, and the instantiate method returns the root node of this structure.
      - add_child expects a node as an argument, so this is why it didn't work at first.
      I hope this helps!

    • @DemKartal
      @DemKartal 11 месяцев назад +1

      @@JumboGamedev Thank you for confirmation and the detailed explanation!

    • @JumboGamedev
      @JumboGamedev  11 месяцев назад

      @@DemKartal You are very welcome!

  • @antimari22
    @antimari22 Год назад +1

    welcome back

  • @sapbucry
    @sapbucry Год назад

    Awesome, keep em coming!

  • @MohamedSamy-vp2pq
    @MohamedSamy-vp2pq 11 месяцев назад

    best channel ever

  • @simonsaysgray
    @simonsaysgray 10 месяцев назад

    Thank you, works very well! For some reason, it jumps from 0.4 to 1.0, but maybe it's just the scene i'm loading...

  • @UnstoppableTigra
    @UnstoppableTigra Год назад +1

    Hey, good to see new video from u. Is it new thing background loading implemented in last versions? or it was here long time?

    • @JumboGamedev
      @JumboGamedev  Год назад +1

      Hey, thank you!
      Yes, it is a new way to do background loading added in Godot 4 ( github.com/godotengine/godot/pull/36640 )

  • @Erwjable
    @Erwjable Год назад

    Excellent explained, thanks!

  • @Mik-kv8xx
    @Mik-kv8xx Год назад

    Yoooo look who's back

  • @Sunny_Lapiz
    @Sunny_Lapiz Месяц назад

    Perfect video, Thx a lot

  • @suthamonhengrasmee8182
    @suthamonhengrasmee8182 Год назад

    Great tutorial. Thank you.

  • @AlvaroLand
    @AlvaroLand 2 месяца назад

    Excellent video. Do you know if background loading is possible with single thread mode? Now that the web export has this single thread option many people like me will use it to avoid problems with the browsers but I can't find a way to load scenes without freezes.

    • @JumboGamedev
      @JumboGamedev  2 месяца назад +1

      The documentation of 4.3 for background loading is: docs.godotengine.org/en/stable/tutorials/io/background_loading.html#background-loading
      And it doesn't specifically mention your use case.
      If you want to do background loading on the main thread without freezes, I think you will have to interleave the execution of the game and loading the resource. You can manually read the file in small chunks during each frame (e.g., in the _process() function). This will reduce the risk of blocking the main thread. Consider using `get_buffer()`. docs.godotengine.org/en/stable/classes/class_fileaccess.html#class-fileaccess-method-get-buffer
      You can adjust the length as needed. After that you will have the file content, and you can load them as a resource. Hopefully, this will work!

    • @AlvaroLand
      @AlvaroLand 2 месяца назад

      @@JumboGamedev Thank you, I will try that!

  • @proevilz
    @proevilz 8 месяцев назад

    Damn you sound like a calm Jon Zherka

  • @morganstrauss8516
    @morganstrauss8516 Год назад

    Nice tuts!! thanks!

  • @VRNocturne
    @VRNocturne 10 месяцев назад

    Hello!
    I just saw this and was able to implement it into my game.
    However, one question: I notice that my progress number goes to 50% then 0% but everything loads just fine.
    Hiding the number (replacing with just Loading...) makes it look good and still works correctly, but I am curious as to why the progress stopped at 50% and then went to 0% before loading the finished scene?

    • @JumboGamedev
      @JumboGamedev  10 месяцев назад +1

      Hello!
      I think the behavior of load_threaded_get_status depends on the scene being loaded, so it is hard to exactly know why this may be happening. It is an interesting scenario; my guess is that at some point through the loading process, more dependencies were discovered (or needed to be loaded), and these dependencies were too many & enough to make the amount that was already loaded negligible. You may find these resources helpful, if you want to go into more detail ( github.com/godotengine/godot/blob/4.2/core/io/resource_loader.cpp#L509 ), ( github.com/godotengine/godot/issues/56882#issuecomment-1377612987 )
      Side note: I think this behavior may change depending on the version of Godot or the OS you are using.

    • @VRNocturne
      @VRNocturne 10 месяцев назад

      @@JumboGamedev Thanks for those links, was an interesting read and glad to know I'm not (yet) going crazy.
      After fooling with it some more, I noticed that the progress goes rapidly to 49% - kinda sits there, goes to 50% and then the scene switches successfully. I think the "save sanity" way is for me to just treat 50% as "100%" and then it will look decent to a player while still showing "hey the game isn't frozen".
      Or go with some other effect and drop the number (a sprite animating, etc).
      The adventures of game dev - when things you didn't think would be a quirk show all their quirks :D

    • @JumboGamedev
      @JumboGamedev  10 месяцев назад

      @@VRNocturne You are very welcome. I agree, I would also stretch/redistribute the first 50% to cover a substantial part of the 100%. You may want to use a non-linear function that will take the progress value, and it will return the stretched value. For instance, you may use a power function. I found that y = x^0.2 (where x is the progress value) gives a decent distribution.
      Indeed, game dev is really interesting!

  • @morganp7238
    @morganp7238 3 месяца назад

    subbed and liked, thanks

  • @gnomemann6986
    @gnomemann6986 9 месяцев назад

    Very useful, but I have one question. If I wanted to use this function but make the loading wait for a function in the next scene to be run how would i do that?

    • @JumboGamedev
      @JumboGamedev  9 месяцев назад

      If you want to run a function before switching to the new scene, you can run this function before the line `get_tree().change_scene_to_packed(newScene)`.

  • @ilsukketto
    @ilsukketto 3 месяца назад

    How do I increase the loading time by, say, 5 seconds after the scene has finished loading?

    • @JumboGamedev
      @JumboGamedev  3 месяца назад

      You can use a Timer node, and use the timeout signal. Then, you can set the wait_time, and start the timer. docs.godotengine.org/en/stable/classes/class_timer.html

  • @MrGold-zn1xo
    @MrGold-zn1xo Год назад +1

    What determines a scene being finished loading? i have a scene with procedurally generated a world, but is that scene immediately "loaded", while the generation still continues to happen?

    • @JumboGamedev
      @JumboGamedev  Год назад +1

      When we talk about a scene being loaded, we are generally referring to the process of taking a scene file (like .tscn) from the disk and bringing it into memory. This way we can interact and instantiate the scene. If you have scripts attached to a node in your scene that perform procedural generation when the scene starts up, that logic will execute after the scene is instantiated from the loaded data.

    • @MrGold-zn1xo
      @MrGold-zn1xo Год назад +1

      @@JumboGamedev Thank you! That's what I thought. Do you know would I add a loading bar in my case?

    • @JumboGamedev
      @JumboGamedev  11 месяцев назад +1

      @@MrGold-zn1xo Yes, I think it is a good idea to add a loading bar.

  • @ZurtPIZZA
    @ZurtPIZZA 2 месяца назад

    Hola, no se mucho ingles pero quisiera que me asesoren. Cuando testeo mi juego en mi PC todo funciona, las instancias, las escenas, todo, el problema es cuando oo exporto a android. Algumas veces no entra al juego, otras veces se queda atascado en el menu principal y ahora que aplique este tutorial el resource loader me lanza un 2, que siignifica que hubo un error. No se que es exactamente soy principiante en esto y no quiero abandonarlo por un bug confuso

    • @JumboGamedev
      @JumboGamedev  2 месяца назад +1

      Hello!
      Some possible reasons to consider:
      - Make sure that you have the correct path to the resource. For example, ensure that the paths use `/` as the separator instead of `\`.
      - Mobile devices usually have less memory available (compared to PC). If your game uses a lot of resources, you might run out of memory, causing resources to fail to load. Maybe try to reduce the size of the textures, models, or other resources, if they are large.

  • @fidgety48
    @fidgety48 7 месяцев назад

    my game still freezes when this process happens? it may have something to do with the fact that im using an autoloaded object but im not sure

    • @JumboGamedev
      @JumboGamedev  7 месяцев назад

      If your game freezes at some point, this likely means that there is some operation that blocks the main loop. It doesn't have to be the autoload.

    • @fidgety48
      @fidgety48 7 месяцев назад

      @@JumboGamedevthe mistake was that i compensated the process with a while true loop! a mistake on my part, i solved it by adding "await get_tree().process_frame". thank you for the tutorial!

  • @noodledealer7447
    @noodledealer7447 6 месяцев назад

    Goated

  • @delalexofficial
    @delalexofficial 7 месяцев назад

    Perfect! + sub

  • @velixgd9312
    @velixgd9312 3 месяца назад

    Why does the error 'Invalid get Index "progress" (in base string)' appear?

    • @JumboGamedev
      @JumboGamedev  3 месяца назад

      It seems that you have `progress` as a string and you are trying to get a character that is out of bound. I think you need to make sure that progress is an array and you are accessing the value in index 0.

    • @velixgd9312
      @velixgd9312 3 месяца назад

      @@JumboGamedev Thanks

    • @JumboGamedev
      @JumboGamedev  3 месяца назад

      @@velixgd9312 You are welcome!

  • @lofinotion
    @lofinotion Год назад +1

    nice video! thanks. but...your chatting sound in the video keeps making me check my gogole chat~ aha

    • @JumboGamedev
      @JumboGamedev  Год назад

      Thanks for the feedback! I will try to work on the audio more. It would be helpful if you let me know what aspect of the sound needs to be adjusted? does it need to be louder?

    • @felemeria
      @felemeria Год назад

      I would use a different sound effect because it sounds just like a chat message. I have that same issue on all of your videos, but I appreciate the content.@@JumboGamedev

  • @yacoobsc.m3269
    @yacoobsc.m3269 23 дня назад

    Que dedicación mas exquisita a un video, se puede hacer mejor ? lo dudo

  • @vseodbornik
    @vseodbornik Месяц назад

    how do i do this in c# though?

    • @JumboGamedev
      @JumboGamedev  Месяц назад

      I have not used C# for a long time. But I think you just need to use PascalCase version.

  • @lethn2929
    @lethn2929 11 месяцев назад

    Okay, I'd just thought I'd drop another bit of knowledge I ended up getting from the Godot contributors chat. I was getting some exceptionally nasty errors and scene corruption issues awhile after with error messages like 'circular dependency'. If you are ever getting these errors, check the referenced scene and script, go into the script and change any 'preload' scenes you have to 'load' this should then fix the problem, the way they've gone about it is cancer though so I'm going to see if they can post up either some kind of documentation or update their error to explain this better because it was the first time I'd encountered this and it's terrifying when you first get it.
    Edit: Not doing this can cause huge problems even when you're just in the editor because of the way preloading works it seems even I even found myself having problems even after I removed the loading scripts.

    • @JumboGamedev
      @JumboGamedev  11 месяцев назад

      Thank you for sharing!

    • @Nazsgull_
      @Nazsgull_ 11 месяцев назад +1

      "Scene file [scene_name] appears to be invalid/corrupt"... This thing has been giving me a headache for a few days, I'll try your fix and see if it works.
      Edit: it works

  • @lethn2929
    @lethn2929 Год назад +1

    In case anyone is wondering how to do a progress bar for loading.
    loadingProgressBar.value = floor(progress[0] * 100)

  • @blueroman460
    @blueroman460 Месяц назад

    Thanks for the video!