WTF are Resources for in Godot?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

Neat! Now I don't have to save everything into an array as a barbarian.

👍︎︎ 2 👤︎︎ u/DaisyGamesStudio 📅︎︎ Aug 23 2021 🗫︎ replies
Captions
so let's talk about resources through example we have this config class here this problem we all have we want to save configuration of our game to disk so my config has the volume a bool to show the tutorial or not and the input map so think about the code you might have to write to save this you'd have to loop over all the input map blah blah no resource saver save this is all the code to save this guy and then if we want to load it back in we just say load and then here i have a little check just in case it's not there i create a new one and then we go over the input map we saved and we just reapplied to the project settings this works because input events are resources themselves so i have a little test here that sets different values on the config saves and then it's going to open up my user directory using this cool little helper function globalize path so we have config config.trez here's the volume show tutorial and our input map saved so let's look at another great use of resources i have this problem i have a bat a skeleton and a spider in my rpg and i want to give them all stats like health magic how much attack they have i wanted to show up in the inspector so i can easily edit it but that's not going to work because bat is a rigid body skeleton is a kinematic body and spider is a sprite so if i just add a script with export variables they can't be shared i'd have to rewrite it i have to copy past it so how can resources help me well we can export resources check out the backs the batch script we export the resource and we call it stats so then let's look at the stats class i've written previously it's a resource called stats has help magic and attack floats from zero to one pretty simple and we apply it by clicking on the bat go into the inspector scroll down down and down and down we find new stats open it up and hey it works now we can adjust these guys and it gets even cooler because let's say you say well you know i think all these guys should have the same stats they're all the same class and monster or whatever so now you could go to resource save i'm going to save it as easy monster and then here i can just drag it on and if i change it for one person let's say you're balancing the game i could say well i think i want the health of the easy monster just to be a little bit more the magic to be a little bit less so that's another really really useful use of resources and again saving your game now be very trivial because you just have to loop over all your entities and save their stats i hope resources seem useful if any questions about that stuff there is a link to a discord in the description it's for a game i'm making but i'm on there all the time pretty active if you want to come talk to me about anything cool thanks
Info
Channel: samsface
Views: 1,966
Rating: undefined out of 5
Keywords:
Id: sNjpSAcC878
Channel Id: undefined
Length: 2min 56sec (176 seconds)
Published: Mon Aug 23 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.