How to Create SAVE & LOAD in Godot 4

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ก.ย. 2024

ความคิดเห็น • 78

  • @firewolf11567
    @firewolf11567 8 หลายเดือนก่อน +21

    I came across your older save and load tutorial through the algorithm, then decided to look at your channel and saw you uploaded this 4 days ago! I recommend adding a pinned comment to your older tutorial linking to this one! Great job, and thank you!

    • @dev-worm
      @dev-worm  8 หลายเดือนก่อน +7

      youre right, thanks for reminding me! glad it was able to help!

  • @tiagogarcia4900
    @tiagogarcia4900 8 หลายเดือนก่อน +60

    Hmmm I'll be saving this for later

    • @Memose2
      @Memose2 8 หลายเดือนก่อน +8

      Best comment I read so far

    • @MdTahsinMazhar-qr7uw
      @MdTahsinMazhar-qr7uw 2 หลายเดือนก่อน

      Seriously, you'll be "saving" 😅

  • @4U4U7
    @4U4U7 6 หลายเดือนก่อน +1

    Hi DevWorm! Just want to thank you so much, I have had troubles saving persistent data and just could not get it to work but I have solved it with your help! Keep well and keep up the good work.

    • @dev-worm
      @dev-worm  6 หลายเดือนก่อน

      so glad to hear!! thank you so much!

  • @lucasmence
    @lucasmence 8 หลายเดือนก่อน +5

    I don't use godot yet, but I love to watch your videos about game dev, keep it up! Cheers!

    • @dev-worm
      @dev-worm  8 หลายเดือนก่อน +2

      I appreciate that!

  • @leandroverse
    @leandroverse 6 หลายเดือนก่อน +2

    Why changing the resource in every frame? Couldn't it be changed when saving, like calling UpdatePos inside save() before ResourcerSaver?

  • @debunkler
    @debunkler 4 หลายเดือนก่อน +7

    Cool guide for small games! But somewhat falls apart at scale.
    You'd need to create a centralized save/load structure with an inheritance paradigm instead of this coupled strategy.
    Also, saving directly as a .tres leaves the save file really vulnerable to security risks (injecting code, changing values). You can use Safe Resource Loader from the asset library to load a Resource more securely.

    • @azumashinobi1559
      @azumashinobi1559 17 วันที่ผ่านมา

      If you don't mind could you explain why this wouldn't work with large scale games? I'm working on a project that I think is small enough but I wanna be sure.

  • @SollyVlogs
    @SollyVlogs 7 หลายเดือนก่อน +1

    Thank you for the tutorial, super helpful :) !

    • @dev-worm
      @dev-worm  7 หลายเดือนก่อน +1

      so happy to hear

  • @alli-gator-forest
    @alli-gator-forest 7 หลายเดือนก่อน

    Thank you for this amazing video!
    Personally, I wanted to load my Resource using the _ready() function, so I changed the load_data() function to add the following if statement:
    if ( ResourceLoader.exists( save_file_path + save_file_name ) ):
    playerData = ResourceLoader.load( save_file_path + save_file_name ):
    This ensures it won't try to load a file that doesn't exist on the very first time running the line of code, allowing you to call the load function before you make a save.

    • @dev-worm
      @dev-worm  6 หลายเดือนก่อน

      ah yes!! thanks for pointing that out!!

    • @Lupin_VA
      @Lupin_VA 6 หลายเดือนก่อน

      mine spontaneously stopped working and this fixed it thank you

  • @therealcherrypapa
    @therealcherrypapa 3 หลายเดือนก่อน +1

    You saved me a lot of time.

    • @dev-worm
      @dev-worm  2 หลายเดือนก่อน +1

      so happy to hear!!

  • @strike5382
    @strike5382 2 หลายเดือนก่อน

    this really helped me with understanding this, thanks

    • @dev-worm
      @dev-worm  2 หลายเดือนก่อน

      so glad to hear that!! if you need help with anything just let me know!!

  • @reesekelly2388
    @reesekelly2388 8 หลายเดือนก่อน +2

    Great video. I really like the idea of using resources to save however there are a lot of people who are saying that if a player downloads files for your game it can breach their security. Is there a work-around for this? I also want to implement multiple saving slots so maybe I should just use JSON... even though it's a lot less intuitive.

    • @reesekelly2388
      @reesekelly2388 6 หลายเดือนก่อน

      Update: I got everything to work using JSON except the player inventory which is a resource. I think I am going to have to revert to the version of my game I had a month ago and implement a resource system instead of JSON. I have tried so many different methods. I would love to see @DevWorm's solution to saving an inventory because my inventory system is pretty similar to the one in his other video. It would help greatly Thanks!

  • @xmacherie
    @xmacherie หลายเดือนก่อน

    Thank you so much for this tutorial, it was very simple and easy to understand. I have a question - if I want to add some additional parameters to the save file, such as on a RPG with a map with changes in scenes, I would just theoretically save the scene path that the player is in and load that scene path?
    I want to make it an open exploring game and keep track of where the player is on the map, quest status, item spawn status, etc. and feels like it could get pretty confusing pretty fast. Thank you!

  • @i_draw_whatever18
    @i_draw_whatever18 2 หลายเดือนก่อน

    What if instead of pressing a button to save we want to save the progress we’ve made in one scene before changing to the next one?
    Like say you collected coins from scene 1, then you go to scene 2 to collect more before going back to scene 1, only to see the coins you had collected are back at their place again.

    • @dev-worm
      @dev-worm  2 หลายเดือนก่อน

      then you would have to save them in different files!! so for instance have a scene1 data file and a scene2 data file. and load those files in and out when the scene is switch to and from.

  • @Kirbo-The-Dirbo
    @Kirbo-The-Dirbo 8 หลายเดือนก่อน

    I needed this so bad. Thanks

  • @MultiLeandrini
    @MultiLeandrini 8 หลายเดือนก่อน +1

    This exactly what I wanted/needed/was looking for. What is this timing? thanks

  • @PerfectUbaid
    @PerfectUbaid 8 หลายเดือนก่อน +1

    Hi man very interesting video

  • @cheapgrams2955
    @cheapgrams2955 8 หลายเดือนก่อน +4

    Hey Dev! Since I’m early I want to use my newfound comment powers to request an inventory system!! I feel like you could explain one in a simple and replicable way! Much love and thank you for the dope tutorials!

    • @thesomeone2nd
      @thesomeone2nd 8 หลายเดือนก่อน +1

      He already has 2 videos for that go check them out.

    • @dev-worm
      @dev-worm  8 หลายเดือนก่อน +1

      Just uploaded a really simple and for sure easily replicable 2 part tutorial series not long ago, I hope that is able to help

    • @cheapgrams2955
      @cheapgrams2955 8 หลายเดือนก่อน

      Ah yes I see, excuse my ignorance. Just excited to learn I guess lol shoulda looked deeper!

  • @WunderChilld
    @WunderChilld 7 หลายเดือนก่อน

    Thanks for the videos brother, could you bring a video explaining how to enter/use some type of vehicle? whether horse, car, etc.

  • @MrStarlightt
    @MrStarlightt 8 หลายเดือนก่อน +1

    so does this save the game when i close the game, like will the player be in the saved position next time i open the game or is this a save system for a running game only?

    • @dev-worm
      @dev-worm  8 หลายเดือนก่อน +1

      yes if you save the data then close the game it will still keep that data saved for when you open the game back up

  • @asd1-so5sl
    @asd1-so5sl 5 หลายเดือนก่อน

    What if I want to change the translated language?
    I've already done it so that when you click the buttons, the language of the game changes, but I want to save it.
    So when I reopen the game, if i had set the game to french, it opens in french. If I change it again to English, close it, and open it again, it should be in English.
    While I understand that it has the same method, I don't understand the coding part of it.
    I need a youtube tutorial on it please. can't find one.

  • @ROSACEPONY
    @ROSACEPONY 6 หลายเดือนก่อน

    Can you make a tutorial on how to make a character selection screen that also include a character creator and being able to save our character in a slot/list? (this definitely not for my game i swear😁)
    On a serious note, it could benefits a ton of gamedev as it's very common in RPG to have a character creator+selection screen.

  • @jasonwilliams8730
    @jasonwilliams8730 8 หลายเดือนก่อน

    Epic tuts!

  • @Manimanocas
    @Manimanocas 2 หลายเดือนก่อน

    Im sorry for commenting but do you think this is a good way of storing health, acquired skills etc across scenes?

  • @HippocritterXD
    @HippocritterXD 8 หลายเดือนก่อน

    this is a great video thanks for making it. i was wondering are you gonna continue with the survival game series?

    • @dev-worm
      @dev-worm  8 หลายเดือนก่อน

      any ideas for what could be next??

    • @gamer20_
      @gamer20_ 8 หลายเดือนก่อน

      maybe add this saving and loading
      @@dev-worm

    • @HippocritterXD
      @HippocritterXD 8 หลายเดือนก่อน

      @@dev-worm maybe a boss with a few mechanics

    • @HippocritterXD
      @HippocritterXD 8 หลายเดือนก่อน

      @@dev-worm or a level up system

  • @adrianvazquez8686
    @adrianvazquez8686 8 หลายเดือนก่อน

    Hey!! Would you make a tutorial on how to make a good menu and UI?? It'll be really helpful!!

    • @dev-worm
      @dev-worm  8 หลายเดือนก่อน +1

      working on one now!!!

    • @adrianvazquez8686
      @adrianvazquez8686 8 หลายเดือนก่อน

      @@dev-worm thx man!!

  • @wellplayedggwp295
    @wellplayedggwp295 8 หลายเดือนก่อน

    I make resource of each collebtible items and export them to external resource file, and There is dynamic var inside resource which is amount(default is 0), but whenever i tried to make changes and load it, its always reset to its default var, is it Only saving the reference? Or I should not export each item and define them inside the code instead?

    • @dev-worm
      @dev-worm  8 หลายเดือนก่อน +1

      export each item and when changing the var make sure to do so in the external resource file

  • @CAlexRPG
    @CAlexRPG 4 หลายเดือนก่อน

    I'm getting a "cannot call method 'duplicate' on a null value, not sure what to do, it saves fine, just doesn't load

    • @CAlexRPG
      @CAlexRPG 4 หลายเดือนก่อน

      Nevermind, I forgot to make the save file .tres

  • @GameLog0
    @GameLog0 7 หลายเดือนก่อน

    I am a bit confused. I was planning on using this as a guide for a save/load system, but how would I reset the save file if i want to start over?

    • @Lupin_VA
      @Lupin_VA 6 หลายเดือนก่อน

      thats what im trying to figure out i accidentally put my player in a void ;-;

  • @uiet6527
    @uiet6527 6 หลายเดือนก่อน

    I'm making a 2d game using your all tutorials but I'm stuck with save and auto load when i exit and enter the game and i can't understand how the save and autoload works !
    Can you make a simple auto save and load video for simple game please

  • @rayoxp
    @rayoxp วันที่ผ่านมา

    "I want to save the scene path when a player moves from one scene to another and save it in a JSON file in Godot 4."

  • @fulla1
    @fulla1 8 หลายเดือนก่อน

    This resource file is only temporary, right? I mean if you restart the game it will always start with the same location and health.
    In other words: is this adaptable to have e.g. EXP, current level, ... saved permantently and load it on the next start of the game?

    • @dev-worm
      @dev-worm  8 หลายเดือนก่อน

      no its not temporary, it saves into that folder and file we created as variables. so if you close the game and come back then it will keep the saved data

  • @HoberMallow-tg3ph
    @HoberMallow-tg3ph 5 หลายเดือนก่อน +2

    Can you explain using .duplicate(true)?

  • @uiet6527
    @uiet6527 6 หลายเดือนก่อน

    In future video can you make this video for clear explanation for beginners like me

    • @dev-worm
      @dev-worm  6 หลายเดือนก่อน +2

      what arnt you understanding? maybe I could clear it up for you!

  • @Whhatt
    @Whhatt 8 หลายเดือนก่อน

    Can you please make a tutorial on deceleration on a 2d platformer
    Good vid btw

    • @dev-worm
      @dev-worm  8 หลายเดือนก่อน +1

      working on it!!

  • @F_Du_Sea
    @F_Du_Sea 6 หลายเดือนก่อน +4

    Is there no easier way to do this? This seems really convoluted, and the tutorial itself doesn't help either. You have functions change_heath and UpdatePos (I'd stick to one naming convention, by the way) which have nothing to do with actually loading and saving. My point is that the code you write should be portable. Anyways, isn't there a way to do something like this?:
    # World Data
    with open("saves/save.json") as saveFile:
    data = json.load(saveFile)
    # Use Case
    if keys[pygame.K_e]:
    for chest in data["chests"]:
    if data["player"]["x"] == chest["x"] and data["player"]["y"] == chest["y"]:
    chest["open"] = True
    # Another Use Case
    xCamera = data["player"]["x"] - (xMax // tileSize) // 2
    yCamera = data["player"]["y"] - (yMax // tileSize) // 2
    In this code, the loading & saving are clearly displayed, and there is a use case. In this tutorial I can barley tell the two apart. Another criticism I have is the length of the video. There is absolutely no way you need 20 minutes to explain a concept as easy as literally opening a file, then reading & writing from it. You made a tutorial on how to make your game, not how to save and load files.

  • @domaa_h
    @domaa_h 4 หลายเดือนก่อน

    TYSM

    • @dev-worm
      @dev-worm  4 หลายเดือนก่อน +1

      glad it helped!!

  • @planktime
    @planktime 8 หลายเดือนก่อน

    HELLO!

    • @dev-worm
      @dev-worm  8 หลายเดือนก่อน

      HELLO!

    • @planktime
      @planktime 8 หลายเดือนก่อน

      @@dev-worm Thanks for coming through on that.... My GF is now saying hello the same way.

  • @tonnypedersen5915
    @tonnypedersen5915 8 หลายเดือนก่อน +3

    using resource files for save game system is a bad idea, they are not safe for use in user land, they are perfect for actual resources in the game and nothing else, for save game use a text based system or a actual database like SQLite or similar, it is also a good idea to encrypt the save file to prevent cheating.

  • @jeremiahaemile2008
    @jeremiahaemile2008 8 หลายเดือนก่อน

    thanks man
    i will watch it in my a vaction
    and ya i am jeremiah but i change my profile picture

    • @dev-worm
      @dev-worm  8 หลายเดือนก่อน +1

      thanks jeremiah so happy to see you brother!

  • @MochiRosu
    @MochiRosu 8 หลายเดือนก่อน

    MCSQUIRMY!!