Saving and loading games with Godot

Saving and loading games with Godot

Godotneers

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

34,512 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@georg_wacker
@georg_wacker - 05.02.2024 14:06

For the ResourceSaver you can change the file type from "tres" to "res" to save it in binary format.

Ответить
@AsePlayer
@AsePlayer - 03.02.2024 03:25

Based fellow Camtasia enjoyer

Ответить
@mdivs
@mdivs - 02.02.2024 15:34

Man thank you very much what a great video!

I have two considerations I think is missing from the video:

1) you can use dictionaties in saved_data so this way you dont need to create a lot of resource class one for each save data you need. ResourceSaver will understand and keep Godot data like Vector2 when using this aproach since the dictionary is inside a Resource.

2) Formats like JSON are really good for web, so if you want to have some cloud saved game (and mainly generate analyses of your players data) i would surely recommend to save it into JSON. The Godot Resource format (.tres) will need to be serialized to be sent to web and it will be very hard to have some data analyses in the server-side. Even if you game dont use server-side operations you should question yourself about scalability before choosing to save data in Godot Resources.

Some time ago I tried to create a script that could recursively parse all custom data from a Godot Object (all custom variables), I saw that it is possible but requires a lot of work to make it fully functional so I gave up. If you guys develop some solution that can do something like that, this is just going to be insane to convert all recurse data to JSON without lose Godot native typos with a single line of code. When I saw this was gonna take me something like 7 or 8 weeks of development I gave up.

Ответить
@antimari22
@antimari22 - 02.02.2024 12:19

I don't know why. but you must use "@export" your save resource even if you don't want change value in inspector. without @export, save doesn't work proper. it didn't save sub resource.

Ответить
@viruschris3160
@viruschris3160 - 02.02.2024 11:50

Just saw this in my recommendations today and I’ve been looking at tutorials to learn Godot.

Aside from GDQuest this is another awesome channel showcasing how Godot.

I’ll have to come back later to learn.

But this will help a lot when setting up a save system. And one explaining in every detail to help newcomers and such.

I wish more tutorials were like this. They just jump right into doing it without explaining and showing the steps properly that I just copy and not learn how to do things.

Ответить
@RaidPerspective
@RaidPerspective - 01.02.2024 10:07

You teach like my first programming professor in college who I consider to be the best teacher I ever had. So many tutorials look to rush through as quickly as possible in an effort to satisfy the ADD generation. You break the mold and look to work people through common problems and pitfalls people have. Thank you for taking the time and giving me what I'm really looking for when approaching game development learning.

Ответить
@-monuyadav-
@-monuyadav- - 30.01.2024 14:57

Hi. This is a great video. Using the resource approach I implemented the save and load mechanism in my game. However my game also has a reset function that should restore the last saved data of the loaded game. I tried using duplicate(true) but array and dictionaries with other resources as values are not deep copied. Then I tried get_property_list() function but to recursively copy it myself. But get_property_list() returns a lot more than just the properties I have defined in my custom resource and at some point it the deepcopy is in a invalid state. I tried looking for help on various forums and also created a proposal for a proper deepcopy function.

Could you guide me on how I can create a deepcopy of my save file that has Dictionaries and Arrays which themselves have other resources?

Ответить
@LuisCassih
@LuisCassih - 30.01.2024 00:35

For compatibility on new changes to the save game structure, a nice approach used by databases is to have a migration table. When you create a save data file, you also store a version numer of the current Save Data structure. So each time you need to change the structure, you increment the version and create a migration function who convert the previous version to the newer one.
That way, for example, if the user had a very old save data, the system will read what version is, and will loop for each migration function executing their converter until the save data is upgraded to the newest version.
But yeah, it's a long topic to talk about ^^

Ответить
@hootis1
@hootis1 - 28.01.2024 23:49

please stop using AI art in thumbnails

Ответить
@MrGold-zn1xo
@MrGold-zn1xo - 26.01.2024 19:56

Is there a way to save nested resources? My character resource has an inventory resource attached to it, and on that an array of slots (more resources). Trying to reload the inventory gives me an error - invalid index 'item' on base: 'Resource'. I've tried to change the saver to include ResourceSaver.FLAG_BUNDLE_RESOURCES, but no luck just yet. Any tips? Thank you

Ответить
@greyly_
@greyly_ - 26.01.2024 16:37

I noticed that you used the number 4711 as a dummy id. Back in the 80's and 90's, programmers commonly used 4711 as the numerical equivalent of foobar here in Sweden. I thought that was only a local thing we did, but you don't sound Swedish.

Ответить
@lordsilica
@lordsilica - 24.01.2024 01:31

Your tutorials are awesome! Thank you.

Ответить
@UsedNacho
@UsedNacho - 23.01.2024 14:09

I like that you explain why we do things rather than just giving us the solution because that is so helpful!

Ответить
@TaianRmos
@TaianRmos - 22.01.2024 21:03

That was a great video man ! Love it !
I have a question about security, do you think it would be viable to have a .tres file containing the saved data and encrypt the file every time ?
I'm wondering because I'm worried it could ruin the game's performances, but at the same time it would help a lot with security issues, for example using an encryption using a private key or something like this.
Do you have any idea if that would be possible and how ?

Ответить
@CaroLose
@CaroLose - 21.01.2024 12:04

May I ask you a question, the example in the video is a single level, so every time you save the game, you will save the entire level again.
Q1: What if the game allows players to go to the next level, but also allows players to return to the previous level, how should it be saved then?

Also, the fish that have been destroyed in the level will not call _on_save_game, so there will be no existence of this fish in the save, and it will not be reloaded when the level is restored, so far so good.
Q2: If in the next version of the game you add another fish to the level, but because there is no record of this fish in the old save, will it be mistakenly judged as this new fish has already been destroyed when loading the game?

Ответить
@a.bcd_or_EFG
@a.bcd_or_EFG - 19.01.2024 07:09

this is best godot tutorial

Ответить
@MultiLeandrini
@MultiLeandrini - 19.01.2024 03:10

Your videos are so amazing, you have so much talent to teach! You showed me I was a horrible programmer in a good way, now I know how to improve. Thank you!

In this specific topic of game saving it just seems like a hassle to save everything and as things scale with levels or maps and a lot of classes and game objects this does seem exponential work. I wonder if there is a way to make it so that we can save a "game object" with everything that is important to each object. Ex: the torpedo has the position, direction, angle. Why not store the "Transform" component itself? Is it possible? Is it also possibly to create an object that stores all the variables in a given gameobject (like a table object where we put the damage of the torpedo, the velocity, etc - so that we only save 1 thing per obejct - the table)?

Ответить
@Fatalhck
@Fatalhck - 18.01.2024 00:58

Out of curiosity is there no way to have some straightforward approach like dumping memory and loading it again? IDK just worried about the demand of creating new classes and business logic for the sake of saving/loading in a bigger game.

Ответить
@adriantatomir2375
@adriantatomir2375 - 18.01.2024 00:04

Best tutorials! MORE PLS

Ответить
@davids.2816
@davids.2816 - 17.01.2024 23:10

I would really appreciate a video on cameras. Especially RTS-style ones.

Ответить
@Cartkun
@Cartkun - 16.01.2024 07:56

Excellent video very informative. Thanks.

Ответить
@jonasan77
@jonasan77 - 15.01.2024 22:05

Thank you for the great video and the SafeResourceLoader plugin!

Ответить
@antivirusjrelax9155
@antivirusjrelax9155 - 15.01.2024 02:51

Thank you so much, it's really too easy explained and with lots of examples, issues and resolves. Your voice is also cool! I hope you'll continue to make tutorials. I would buy your courses if you make them😁

Ответить
@psielemental
@psielemental - 14.01.2024 20:18

Actually going through ALL the possible options instead of just one, and actually going through all the pros and cons, very nice. Very nice indeed!

Ответить
@Daniel-ih6uk
@Daniel-ih6uk - 12.01.2024 10:57

Thank you, this video is extremely helpful

Ответить
@5naf_plushies482
@5naf_plushies482 - 12.01.2024 08:59

Words can't describe how helpful your tutorials are! Thank you so much! I never understood saving and loading and there weren't many tutorials on the internet so this video was super informative! Definitely gonna stick around to see more!

Ответить
@Elrinth
@Elrinth - 10.01.2024 11:57

Amazing tutorial! Many thumbs up!

I think TRES vs JSON is pestilence or cholera. The fact you need to add extra files (save data files) for each of your objects is shit for TRES. Also the fact that you are required to add some extra module to make sure scripts aren't ran is shit. Therefore I probably prefer the json. You can add those save/load functions in all objects in the world you wish to save/load and simply iterate over them in the world. Then you won't need extra save data files per object which you wanna save, you simply implement the save/load functions for each object.

Ответить
@yokcos
@yokcos - 09.01.2024 21:25

absolutely phenomenal video. question: if you have an object that stores some other object in a variable, what's a good way to save/restore that? e.g. if a torpedo locks on to a particular fish, you save/load and the torpedo remains locked on to that very same fish

Ответить
@suthamonhengrasmee8182
@suthamonhengrasmee8182 - 09.01.2024 21:17

Thank you very much for a great tutorial. But shall we use .res instead of .tres? since .res is already a binary file and can read easily when throw in Godot.

Ответить
@Zenva
@Zenva - 09.01.2024 02:06

Thanks for making these awesome videos! We would like to discuss doing a sponsored video for our Godot courses if you are interested, but couldn't find any contact information in the channel.

Ответить
@jakefranklin198
@jakefranklin198 - 09.01.2024 00:55

So helpful and valuable. Just made my way through your whole backlog and hope to see more...amazing quality of information and presentation. Thank you!

Ответить
@RasakBlood
@RasakBlood - 06.01.2024 17:38

As a beginner finally at the stage where i need to tackle saving and with a lot of stuff to save this is very good. My brain hurts but its good.

Ответить
@NexamTube
@NexamTube - 06.01.2024 02:46

Thanks!

Ответить
@RobbinWesterlund
@RobbinWesterlund - 05.01.2024 19:26

can you make a tutorial for making a game like cult of luna and don´t starve... like the camera angels and if they use mesh textures och billboarding.

Ответить
@thephoenixstudio
@thephoenixstudio - 05.01.2024 09:08

Any way to use My Documents instead if AppData? AppData is horrible for backups.

Ответить
@Eliasdbr
@Eliasdbr - 04.01.2024 23:18

Thank you so much for these quality tutorials! You are a great teacher. More tutorials should explain using trial and error, especially simulating the mindset of a beginner. You are really good in what you are doing.

Ответить
@kruth6663
@kruth6663 - 03.01.2024 05:16

Is it possible to ask godot to add the option to compile in a way that doesn't allow running scripts in resources?

Ответить
@AJMarraffa
@AJMarraffa - 02.01.2024 19:50

Excellent video! Thanks so much. Big help for me as a solo indie dev.

Ответить
@teo2805
@teo2805 - 01.01.2024 19:49

Enough AI art pls

Ответить
@kruth6663
@kruth6663 - 01.01.2024 06:56

Yeahhh this is exactly what I need, thank you.
This tutorial is SO GOOD!

Ответить
@bencepaul3497
@bencepaul3497 - 30.12.2023 13:48

Another fantastic tutorial! Very easy to follow and I feel like I understand the implications (pros vs cons) of the different save game approaches. Thanks very much for making these!
Looking forward to the next one!

Ответить
@thegamedevclub
@thegamedevclub - 30.12.2023 00:10

THANK YOU! Awesome work brother!

Ответить
@MrSmith_
@MrSmith_ - 29.12.2023 01:57

Do you have a course available? I would very much love to buy it.

Ответить
@Khan-vi5rc
@Khan-vi5rc - 28.12.2023 11:56

I love this tutorial format. Please be the Unreal Sensei of Godot.
(Sorry for the entitlement) Can you make a video on animation

Ответить
@rhyspuddephatt
@rhyspuddephatt - 27.12.2023 03:23

Please raise a ticket for the security concern with the resources and plug it so it gets visibility in the community. I think your suggestion of godot having a built in switch to turn off script injection in resources

Ответить
@AshtonSnapp
@AshtonSnapp - 27.12.2023 00:54

YOU CAN DRAG THINGS INTO THE SCRIPT EDITOR????????

Ответить
@paralaxa
@paralaxa - 25.12.2023 21:10

more videos !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Ответить
@DR_GODOT_DEV
@DR_GODOT_DEV - 24.12.2023 16:47

Great job! This going to help alot of people.

Ответить
@10Dima01
@10Dima01 - 24.12.2023 01:51

Your tutorials are so interesting and useful that I can't stop watching till the end

Ответить
@pancaketree
@pancaketree - 20.12.2023 22:16

wow, great video! so glad I found your channel

Ответить