Тёмный

This Godot 4 Scene Manager Does it ALL 

Bacon and Games
Подписаться 4,7 тыс.
Просмотров 21 тыс.
50% 1

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

Игры

Опубликовано:

 

4 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 88   
@baconandgames
@baconandgames 6 месяцев назад
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. ru-vid.com/group/PLiJ2loFXqTO1_raZB5MhIYLtqdvT5CdSP
@martinrovere7937
@martinrovere7937 4 месяца назад
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 4 месяца назад
That’s really helpful (and kind) feedback. Thank you!
@gdomjan83
@gdomjan83 6 месяцев назад
Thank you for creating more intermediate tutorials. A lot of Godot youtubers are teaching beginners, content like this is sorely needed.
@baconandgames
@baconandgames 6 месяцев назад
Aw, thank you so much. That’s very nice of you to say 🥹
@DavidReidChannel
@DavidReidChannel 2 месяца назад
Really useful video. Also really like this solution to scene management. Thanks for sharing.
@baconandgames
@baconandgames 2 месяца назад
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!
@Peter-wl5xm
@Peter-wl5xm 4 месяца назад
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 4 месяца назад
Thanks Peter! Is there anything in particular you’re looking to learn?
@Peter-wl5xm
@Peter-wl5xm 4 месяца назад
@@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 4 месяца назад
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 🤔
@petterialanen2467
@petterialanen2467 5 месяцев назад
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 5 месяцев назад
That’s wonderful! Keep us posted on your project!
@luckyknot
@luckyknot 5 месяцев назад
Very thorough and well explained tut, really helpful thanks a lot!!
@baconandgames
@baconandgames 5 месяцев назад
That’s very kind. Thank you so much!
@DanielMcNeely
@DanielMcNeely 6 месяцев назад
Thanks for making these great resources for developers.
@baconandgames
@baconandgames 6 месяцев назад
Aw, Dan. 🥹
@nickbdawg6777
@nickbdawg6777 4 месяца назад
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 4 месяца назад
Awesome! Love the pup photo in your profile, by the way. ❤️🐶
@andreamassa2176
@andreamassa2176 6 месяцев назад
Thank you for the tutorial is very interesting and useful, i try to implement a similar thing in my game :)
@baconandgames
@baconandgames 6 месяцев назад
Good luck! Let me know if you get stuck. Thanks for watching. ❤️
@soirema
@soirema 2 месяца назад
wow amazing!!! i need to check it out!!
@miaoumixed4268
@miaoumixed4268 6 месяцев назад
Thank you for your videos (coming from another engine, and want to make a quick transition 😄)
@baconandgames
@baconandgames 6 месяцев назад
You’re quite welcome and thanks for watching! Bonus points for dropping by with a pun. 🌟
@babyjay1386
@babyjay1386 2 месяца назад
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 2 месяца назад
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.
@RafaMartinelli
@RafaMartinelli 6 месяцев назад
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 6 месяцев назад
I’m glad I could help. Thanks for checking it out🙏
@RafaMartinelli
@RafaMartinelli 6 месяцев назад
@@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 6 месяцев назад
@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 6 месяцев назад
@@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 6 месяцев назад
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.
@holdim387
@holdim387 6 месяцев назад
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 6 месяцев назад
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 6 месяцев назад
@@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 6 месяцев назад
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!
@cr0c0dile-Gena
@cr0c0dile-Gena 5 месяцев назад
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 5 месяцев назад
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 5 месяцев назад
@@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 5 месяцев назад
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 5 месяцев назад
@@baconandgames I'll get in touch with you in Discord (same avatar as well 😁) shortly 💚
@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 😀
@nelsonguedespaulojunior977
@nelsonguedespaulojunior977 5 месяцев назад
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 5 месяцев назад
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 5 месяцев назад
@@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 5 месяцев назад
@@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 5 месяцев назад
By the way, this happens using the fade_to_black transition.
@baconandgames
@baconandgames 5 месяцев назад
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!
@exantier
@exantier 3 месяца назад
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 3 месяца назад
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 3 месяца назад
​@@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 3 месяца назад
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 3 месяца назад
​@@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 3 месяца назад
@exantier it’s my pleasure!
@dotspak
@dotspak 5 месяцев назад
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 5 месяцев назад
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 5 месяцев назад
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 5 месяцев назад
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 5 месяцев назад
@baconandgames just added you sorry for the late reply
@baconandgames
@baconandgames 5 месяцев назад
@dotspak all good 🤜🤛
@Fragnatix
@Fragnatix 4 месяца назад
Complaint: Your camera is hidding lots of stuff
@baconandgames
@baconandgames 4 месяца назад
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. 🙏
@Peter-wl5xm
@Peter-wl5xm 4 месяца назад
crow is confirmed dead
@baconandgames
@baconandgames 4 месяца назад
He’s… on a long vacation
@Danny-uo7hk
@Danny-uo7hk 6 месяцев назад
SOUCRE CODE (coming soon)
@baconandgames
@baconandgames 6 месяцев назад
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 6 месяцев назад
Source code link has been added to the description. Thanks for your patience... it was a BUSY month.
@Danny-uo7hk
@Danny-uo7hk 6 месяцев назад
@@baconandgames thank you good sir!
@swampshack1018
@swampshack1018 4 месяца назад
25:37
@baconandgames
@baconandgames 4 месяца назад
Hi 👋 Is there something at that timestamp I should be aware of?
@kishirisu1268
@kishirisu1268 6 месяцев назад
What the point of unloading so tiny scenes? You waste more resourses for i/o operations than gain from unloding.
@azukidere
@azukidere 6 месяцев назад
I mean, as a tutorial, it’s probably meant for games with more performance heavy scenes
@baconandgames
@baconandgames 6 месяцев назад
Correct!
Далее
This Godot SceneManager Does even MORE now!
35:07
Просмотров 3,6 тыс.
Godot Debugging Techniques EVERY Dev Should Know
16:23
Кто понял тот понял
00:24
Просмотров 138 тыс.
Why I Switched To The Godot Engine
6:47
Просмотров 18 тыс.
I Made a Desktop Pet in Godot
16:02
Просмотров 85 тыс.
Phantom Camera For Godot Is Awesome!
10:27
Просмотров 42 тыс.
Improving My Game With Tester Feedback
17:49
Просмотров 168 тыс.
Optimizing my Game so it Runs on a Potato
19:02
Просмотров 456 тыс.
Get This DIALOGUE System For Your Godot GAME Now
42:50
А КАНАЛУ УЖЕ ЦЕЛЫХ 7 ЛЕТ!
16:17
Просмотров 74 тыс.