This Godot 4 Scene Manager Does it ALL

Ойындар

This video will walk you through creating a Scene Manager in Godot 4 that will handle loading progress, displaying transitions, and transferring data between scenes before unloading the newly loaded scene. With this you'll be able to change scenes in your godot project while handling loading and data transfer, all with one line of code :) Transitions included are fading to black, wiping, and zelda-style level transitions.
0:00 - Intro
0:14 - The Final Product
1:48 - How it Works
2:25 - Level Structure
2:47 - Door
4:11 - Door Settings and Export Vars
5:35 - Loading Screen
5:59 - Transitions
7:02 - Loading Screen Code
9:20 - Bird Attack
10:32 - Level Code
13:37 - Scene Manager
15:28 - ResourceLoader & Background Loading
17:17 - Resource Loader Load Status
22:17 - Zelda Style Level Transition
24:02 - Adding New Transitions
27:00 - Displaying a Loading Bar
28:22 - Outro
SOUCRE CODE
baconandgames.itch.io/scene-m...
Assets by KenneyNL
www.kenney.nl/
#godot #scene #manager

Пікірлер: 88

  • @baconandgames
    @baconandgames5 ай бұрын

    If you're looking for more Godot 4 tutorials, check out my Let's Make Snake series which takes you from opening Godot through making a complete game. kzread.info/head/PLiJ2loFXqTO1_raZB5MhIYLtqdvT5CdSP

  • @martinrovere7937
    @martinrovere79372 ай бұрын

    I love that you don't make me copy your code but explain your code and reasonings behind. It forced me to think how to aproach this. Something like "wait, i should be taking notes"

  • @baconandgames

    @baconandgames

    2 ай бұрын

    That’s really helpful (and kind) feedback. Thank you!

  • @gdomjan83
    @gdomjan834 ай бұрын

    Thank you for creating more intermediate tutorials. A lot of Godot youtubers are teaching beginners, content like this is sorely needed.

  • @baconandgames

    @baconandgames

    4 ай бұрын

    Aw, thank you so much. That’s very nice of you to say 🥹

  • @Peter-wl5xm
    @Peter-wl5xm2 ай бұрын

    Thanks for walking through the code and giving us your logic behind it. I'm really excited to see more of your work.

  • @baconandgames

    @baconandgames

    2 ай бұрын

    Thanks Peter! Is there anything in particular you’re looking to learn?

  • @Peter-wl5xm

    @Peter-wl5xm

    2 ай бұрын

    @@baconandgames Hi Sean, appreciate the reply! I'm currently working on an android and steam release single player game. A video on cross-platform general thoughts and implementation tips would be awesome. Just a greedy desire but if it doesn't follow the content totally understood! Your videos are amazing just to reiterate. Will thoroughly watch all of them 😃.

  • @baconandgames

    @baconandgames

    2 ай бұрын

    Thanks Peter! Mobile development and I have a long and storied history 🤣 I’m not sure I can go back down that road… been burned by Google too many times. But I’ll keep that in mind 🤔

  • @DavidReidChannel
    @DavidReidChannelАй бұрын

    Really useful video. Also really like this solution to scene management. Thanks for sharing.

  • @baconandgames

    @baconandgames

    Ай бұрын

    You’re welcome David. Be sure to check out my most recent video. It’s on my godot game template and it includes an updated version of the SceneManager and a bunch of other stuff too!

  • @petterialanen2467
    @petterialanen24674 ай бұрын

    Great content! I'm building a similar type of approach to my game and this helped to wrap my head around the between scenes transitions.

  • @baconandgames

    @baconandgames

    4 ай бұрын

    That’s wonderful! Keep us posted on your project!

  • @luckyknot
    @luckyknot4 ай бұрын

    Very thorough and well explained tut, really helpful thanks a lot!!

  • @baconandgames

    @baconandgames

    4 ай бұрын

    That’s very kind. Thank you so much!

  • @DanielMcNeely
    @DanielMcNeely5 ай бұрын

    Thanks for making these great resources for developers.

  • @baconandgames

    @baconandgames

    5 ай бұрын

    Aw, Dan. 🥹

  • @nickbdawg6777
    @nickbdawg67773 ай бұрын

    Thanks so much for this tutorial! I threw together an incredibly janky scene manager during my last game jam and decided I needed to find a more robust solution and this is perfect for me!

  • @baconandgames

    @baconandgames

    3 ай бұрын

    Awesome! Love the pup photo in your profile, by the way. ❤️🐶

  • @soirema
    @soiremaАй бұрын

    wow amazing!!! i need to check it out!!

  • @babyjay1386
    @babyjay1386Ай бұрын

    Hello, great tutorial! Very well organized and easy to understand. This helped me immensely in my journey to learn game development. If anyone is stuck and failing to load the scene, I added the following line to the ready function of the scene manager in order to connect the signal to the appropriate function. content_finished_loading.connect(on_content_finished_loading) This is necessary in order to actually call the function that loads the level! I also had to create the update_bar function in my loading_screen script. func update_bar(progress): progress_bar.value = progress The modulo expression was not working so I changed the progress_bar path in order to not receive a null instance error. @onready var progress_bar: ProgressBar = $Control/ProgressBar These things may have been in the code, but seem to have not been referenced in the video (perhaps I just missed them). Thanks!

  • @baconandgames

    @baconandgames

    Ай бұрын

    Hey baby Jay, thanks for the comments. Just a heads up, there’s a newer version of this up on my GitHub as part of my Game Template, if you want to check that out. I’ll be maintaining the scene manager and other things there moving forward.

  • @andreamassa2176
    @andreamassa21765 ай бұрын

    Thank you for the tutorial is very interesting and useful, i try to implement a similar thing in my game :)

  • @baconandgames

    @baconandgames

    5 ай бұрын

    Good luck! Let me know if you get stuck. Thanks for watching. ❤️

  • @miaoumixed4268
    @miaoumixed42685 ай бұрын

    Thank you for your videos (coming from another engine, and want to make a quick transition 😄)

  • @baconandgames

    @baconandgames

    5 ай бұрын

    You’re quite welcome and thanks for watching! Bonus points for dropping by with a pun. 🌟

  • @holdim387
    @holdim3875 ай бұрын

    Good day, any particular reason you went with this scene route (that is a scene that contains a player and GUI) and not having one main scene, under which player, GUI, and the level scenes are separate. And loading offloading only level scene, while keeping GUI and player (just changing players position, animating) loaded?

  • @baconandgames

    @baconandgames

    5 ай бұрын

    It's actually really funny you mention that. The game I pulled this from does it the way you describe and it had been my intention all along to make this tutorial work that way. The thing I'm learning as I get into making tutorials is that the more you put in, even as simple as it may be, the harder it gets to clearly talk about certain things OR the longer the video gets. My original cut of this video was over 50 minutes long and over the course of editing, some stuff just has to go, in favor of length, simplicity or both. I was actually debating doing a short follow up showing how to do exactly what you're describing... so maybe I will 🤔 Great question!

  • @holdim387

    @holdim387

    5 ай бұрын

    @@baconandgames I see, I think if you will continue on this, it would be a cool idea to explain pros and cons of both ways for the new developers.

  • @baconandgames

    @baconandgames

    5 ай бұрын

    I really like that idea. I'll add it to the list. You first comment has been one of my favorite so far - I worried about cutting that and you got right to the core of wondering whether I should keep it or not. I think, in the interest of keeping the tutorial more simple and digestible, it was the right call to cut it but I'm glad you called it out because I think showing the next evolution WOULD be a good idea that I wasn't necessarily considering. Again, great question and a great idea!

  • @RafaMartinelli
    @RafaMartinelli5 ай бұрын

    I can already tell this tutorial is so valuable and I’m only a couple of minutes in. Thank you for sharing it!

  • @baconandgames

    @baconandgames

    5 ай бұрын

    I’m glad I could help. Thanks for checking it out🙏

  • @RafaMartinelli

    @RafaMartinelli

    5 ай бұрын

    @@baconandgames it will be useful for what I’m working on, especially cause it looks like your code is really polished. Thank you!

  • @baconandgames

    @baconandgames

    5 ай бұрын

    @RafaMartinelli That’s great! I will be uploading the source code to my itch page tomorrow free to download. I wanted to do that the same day the video came out but it has been a busy month.

  • @RafaMartinelli

    @RafaMartinelli

    5 ай бұрын

    @@baconandgames that’s really appreciated - sometimes people might get feel entitled and forget there’s a human being with a life behind the video. 😅 Plus, one learns a lot more by following along than by just copy-pasting. I’ve discovered through experience with my channel that prioritizing oneself is the best bet long-time! Don’t hesitate reaching out if you need some help!

  • @baconandgames

    @baconandgames

    5 ай бұрын

    I appreciate that. I will probably take you up on that. I’ve only been at this a few weeks, so I’m learning all this in real time. It’s super helpful to have someone to bounce questions and ideas off for perspective. 🤜🤛 I appreciate the self-care advice. Easy to lose sight of that part but you’re right that it’s critical.

  • @nelsonguedespaulojunior977
    @nelsonguedespaulojunior9773 ай бұрын

    Hi. This was an fantastic tutorial, please continue to create such good ones with amazing techniques and details! I noticed that on SceneManager, on the monitor_load_status() callback, even if it's still loading and progressing, you don't rearm the timer, so I guess that after the first time the timer timeout's, you will update progress, and progress will get stuck to that much until end of time. Could not setup a test yet to check this. Is this correct, or I'm wrong?

  • @baconandgames

    @baconandgames

    3 ай бұрын

    monitor_load_status() is called every 0.1 seconds (each time the timer completes). Since the timer is not a one-shot, meaning it restarts itself each time it finishes, it effectively checks the load status 10x per second (framerate aside). So you only need to start the timer once you begin loading a piece of content. After the content finishes loading, the timer is freed and the next time you load something a new timer is created and the process repeats. Does that answer your question? Please forgive me if I misunderstood your question. I THINK perhaps you're thinking of a timer more like one in the real world (like a kitchen timer) that you'd set for 5 minutes and after the time runs out, it buzzes and then is done. Timers in Godot repeat until you stop them (unless set to one-shot) in which case they're more like "loops" than "timers".

  • @nelsonguedespaulojunior977

    @nelsonguedespaulojunior977

    3 ай бұрын

    @@baconandgames Hi, thanks for the answer. Actually, I was looking the loading screen scene and there's a Timer object there and it was configured to one shot. Latter I realized that the one you use on the code is created there and is not the same object. But thanks anyway for the answer.

  • @nelsonguedespaulojunior977

    @nelsonguedespaulojunior977

    3 ай бұрын

    @@baconandgamesI got another problem here, in my case, the Level is bigger than the viewport size and can have multiple rooms that are distant from one and another. When you set the player position you see the map on the default camera position on it (which usually is not on the door) and then it blinks to the player position. I tried a few thinks but still couldn't fix this problem. On my Level, I have the Camera2D object and my player has the RemoteTransform2D. I changed the Level code to actually instantiate the player after it loads and then set the RemoteCamera2D. This works fine. The problem is that we see this blink in the screen showing the position that Camera2D is when you build the map. Any thoughts on that?

  • @nelsonguedespaulojunior977

    @nelsonguedespaulojunior977

    3 ай бұрын

    By the way, this happens using the fade_to_black transition.

  • @baconandgames

    @baconandgames

    3 ай бұрын

    There are a lot of ways you could address that. Without looking at your code, two things come to mind. You could try hiding the player in the _init() function and then showing it after you position it. You could also use a placeholder object like a Marker2D/3D and instantiate your player at runtime instead. These are just two of many solutions you could investigate. Good luck!

  • @dotspak
    @dotspak4 ай бұрын

    Hey I'm having problems loading the actual scene file. On the line var loader = ResourceLoader.load_threaded_request(path), it can't find the path I'm giving it no matter what the file is (I tested with files other than scenes just to be sure). I'm not sure what's wrong, any ideas?

  • @baconandgames

    @baconandgames

    4 ай бұрын

    Under Project (in the menu) try "Reload Current Project" - if you've moved scenes around, sometimes paths or other metadata can get a little gummed up. Are you entering the path in manually or are you using the drag method from the video? If you want to send me some screenshots of your project on Discord @baconandgames I will have a closer look. My guess is there's another error elsewhere but it could be a whole bunch of things. We'll get you straightened out 😉

  • @dotspak

    @dotspak

    4 ай бұрын

    I'm quite experience with the reload project button lol😅I'm using this for a slightly simpler use case than in the video, just transitioning from a title screen to the main game since the main game is currently contained in one main scene (for prototyping simplicity). In my case I'm just doing a call in the title screen code load_new_scene(path), where path is the string I get when I click copy path in the FileSystem. Doesn't change anything when I make an export and put the path there instead

  • @baconandgames

    @baconandgames

    4 ай бұрын

    Hm. Well if you want to hit me up on Discord with your code, I'll be happy to take a look. It's probably something goofy.

  • @dotspak

    @dotspak

    4 ай бұрын

    @baconandgames just added you sorry for the late reply

  • @baconandgames

    @baconandgames

    4 ай бұрын

    @dotspak all good 🤜🤛

  • @cr0c0dile-Gena
    @cr0c0dile-Gena4 ай бұрын

    First of all - great tutorial, thanks a lot! 🙏💚 There is only one issue: I added one spin animation to the loading screen and it's stutters during "heavy" background loading (a few large png pics for testing purposes). I tried to move "monitor_load_status" logic to the "_process", turn off V-sync, make spin animation in code - nothing helps. Any suggestions? 🤔

  • @baconandgames

    @baconandgames

    4 ай бұрын

    Make sure that the call to report_midpoint() (in your AnimationPlayer) is after you TO animation completes. If that call happens too early, Godot will be trying to load the new scene while also playing your animation. If it's in the right place (after for IN transition has finished playing), whatever stutter you're seeing is just coming from the animation itself rather than the SceneManager loading anything heavy. Have a look at that and get back to me. If that doesn't help, we can look at some other things. I would also test the animation you're using itself in a different project (no loading) - you might just need to simplify the animation - more complex transitions than simple fades and wipes can be more efficiently achieved using shaders rather than animations (but we don't need to go there. yet 😀) Thanks for watching and for reaching out. We'll get you squared away 💪

  • @cr0c0dile-Gena

    @cr0c0dile-Gena

    4 ай бұрын

    @@baconandgames Thanks for the quick response! 🙏 The "report_midpoint" call is in the right place and the spin animation is very simple (just one Sprite2D rotating in a loop). I ran some tests: loaded the "heavy" scene and loaded the "base" scene with a delay before calling "finish_transition" (to test the rotation animation) - in the "light" version the rotation animation works smoothly. I also found a thread on the Godot forum with a similar problem, and the thread's author has an idea that the problem comes to the surface when a new scene is instantiated and added to the root tree. 🤷‍♂

  • @baconandgames

    @baconandgames

    4 ай бұрын

    If you have a moment, send me a link to that thread. I'd be curious to read it. YT might flag the post if you put a link here, but my email is on the about page. Or you can hit me up on Discord @baconandgames (with the same avatar as my channel). Does the delay you added solve your problem or does that just rule something out? Let me know how else I can help 🤜🤛

  • @cr0c0dile-Gena

    @cr0c0dile-Gena

    4 ай бұрын

    @@baconandgames I'll get in touch with you in Discord (same avatar as well 😁) shortly 💚

  • @exantier
    @exantier2 ай бұрын

    Dude, this plugin is sick. It helps me a lot with my game. Otherwise, I probably would have had a lot of headaches trying to manage all the doors in my RPG game on my own. Thank you for sahring it! :D However, I have a question: In my game, the camera follows the player on a large map. When he walks through a door, the camera is removed, causing the scene origin (0, 0) to be seen during the screen fade instead of the camera's last position. Would you by any chance know how to fix this? thnks :3

  • @baconandgames

    @baconandgames

    2 ай бұрын

    There’s a couple of ways you can fix this. One, which I omitted from this tutorial would be to keep the camera live a node above your level and instead of destroying the camera and level, just destroy the level. This would mean loading your level into a holder node, instead of the root. I had originally written this SceneManager this way, but it was one extra step to explain so I removed it to make the video simpler. The other thing you can do is to pass desired coordinates for the new camera into the new level (data passing is covered here) so that when you initialize the new camera it’s at the place you want it to be. Both would work, it’s just a matter of preference. I’m glad you found this video helpful!

  • @exantier

    @exantier

    2 ай бұрын

    ​@@baconandgames Sounds good! I tried the first solution. In levels when I only got one door, works excelent. But when I got more of two cameras showing each door (because I have more of one door in some levels level in different places) just it shows the first one on the herarchy instead of the right one. And about the second solution, I think I know what you mean and I think it will be the right solution. But... I don't know how to do it. Can you give me a simple example, please? :3 And very thanks for the fast reply! I'm new at this. You're helping me a lot, dude! qwp

  • @baconandgames

    @baconandgames

    2 ай бұрын

    I’ve had a few people ask me out this setup. I’m going to make a video on it this week. Granted, it probably won’t solve your problem out of the box because you will still likely need to define where you want the camera to start, but that part is easy. Keep an eye out (subscribe and hit the bell and all 🤣). Coming soon!

  • @exantier

    @exantier

    2 ай бұрын

    ​@@baconandgames I really appreciate it, man. I'm already a sub, so I'll be waiting for it haha! Thank you for being so attentive to your community :'3 👍

  • @baconandgames

    @baconandgames

    2 ай бұрын

    @exantier it’s my pleasure!

  • @yubenzuo
    @yubenzuoКүн бұрын

    Really useful video. Thank you so much for the tutorial. But I have a little question. When I run the demo in Godot4.3,the game will be get freezed in the zelda mode. Godot4.3 will report a error,“gameplay.gd:35 @ _on_level_added(): Parameter "p_child" is null.” Is there any way to fix it? Sorry for my poor English,thank you again😀☺

  • @baconandgames

    @baconandgames

    Күн бұрын

    Oh no! Thanks for letting me know. I haven’t tried it in 4.3 yet. But I’ll have a look when I get a free minute and see what might have changed that’s breaking something. And your English is just fine 😀

  • @Peter-wl5xm
    @Peter-wl5xm2 ай бұрын

    crow is confirmed dead

  • @baconandgames

    @baconandgames

    2 ай бұрын

    He’s… on a long vacation

  • @Fragnatix
    @Fragnatix3 ай бұрын

    Complaint: Your camera is hidding lots of stuff

  • @baconandgames

    @baconandgames

    3 ай бұрын

    Response: What do you mean? Are you talking about the headshot covering up part of the file explorer in the bottom left? I don’t think it gets in the way very much, the meat is all up in the code editor. But I’ll be more careful in the future to move it. Thanks for the feedback. 🙏

  • @Danny-uo7hk
    @Danny-uo7hk5 ай бұрын

    SOUCRE CODE (coming soon)

  • @baconandgames

    @baconandgames

    5 ай бұрын

    I’ll bump you here when I have a moment to upload it. I’m on the road but hope to have it up in a few days.

  • @baconandgames

    @baconandgames

    5 ай бұрын

    Source code link has been added to the description. Thanks for your patience... it was a BUSY month.

  • @Danny-uo7hk

    @Danny-uo7hk

    5 ай бұрын

    @@baconandgames thank you good sir!

  • @kishirisu1268
    @kishirisu12685 ай бұрын

    What the point of unloading so tiny scenes? You waste more resourses for i/o operations than gain from unloding.

  • @azukidere

    @azukidere

    5 ай бұрын

    I mean, as a tutorial, it’s probably meant for games with more performance heavy scenes

  • @baconandgames

    @baconandgames

    5 ай бұрын

    Correct!

  • @swampshack1018
    @swampshack10183 ай бұрын

    25:37

  • @baconandgames

    @baconandgames

    3 ай бұрын

    Hi 👋 Is there something at that timestamp I should be aware of?

Келесі