Wonderful tutorial! Straight to the point with examples and visuals. Lovely work
@johnmerriam784417 күн бұрын
fantastic video. Something that had me very confused a newbie learning from this video is you glossed over setting up the _on_button_pressed with their respective signal connections. It would also be nice if you could talk in more detail about how the " %s" worked as shown in the spawn player function. Cheers and keep up the great work
@stabbedbyapanda5 ай бұрын
Thank you, i've watched 4 explanations on Resources, but this one made it the clearest. One thing I'm still struggling to understand is what functions i should contain in a resource vs in the scene script. Still mulling that one over. Ahhh a fellow Unreal dev to Godot!
@chuman719 ай бұрын
Best video on custom resources for Godot 4.x I found so far! thanks!
@Bloom_HD8 ай бұрын
Very good visuals and explanation. Thank you so much!
@qooldeluxx11 ай бұрын
great job, hope to see more godot 4 tutorials, you did a great job explaining.
@oreofilledjoy3027 ай бұрын
Thank you! I've been searching everywhere for a way to load my RPG Job stats!
@brendanhall31816 ай бұрын
Best introduction to resources I've found!
@Marco-L10 ай бұрын
Very nice explanation. Thank you very much.
@scottisitt7 күн бұрын
That was awesome! Thank you! Liked and subscribed.
@alaouiamine38358 ай бұрын
Thank you for the clear tutorial
@isaacdobson87603 ай бұрын
you have a wonderful voice
@danielhalond62928 ай бұрын
great stuff! thanks!
@mkjyt18 ай бұрын
Thank you!
@Evilprince1917 ай бұрын
Great tutorial 😊 May i ask why at 7:02 you load the resource in your method instead of preloading it as export variable like the player scene ?
@Unain7 ай бұрын
Around 7:19 I explain why. We can't preload dynamically created paths, because the program doesn't know on compile time what the string is going to contain :).
@b.c.a6837 ай бұрын
Thank you , Really like your way. I'm new on godot , I have a question : so resources can be used for creating all the items in the game and saved in that data container whenever needed we can call or already loaded in game. for example I got different type , textures ,and stats of 50 swords , 50 maces and 50 spears so should I have a 150 different files under weapon_resources ?
@Zlorak7 ай бұрын
Excellent tutorial, helped me a lot to understand Resources! - I do have one question. I'm working on a RPG card game, where each card has a name, a description, and an effect as a function. It seems like you cannot save functions inside .tres so I guess the right way to save each card would be a scene each?
@Unain7 ай бұрын
You would have one scene that you fill with the information from the card resource. So the texture/description/name you can just get from the resource and load into that scene. For specific card effects I would have a separate node that you can attach to the card which handles the effect. I would recommend checking out: kzbin.info/www/bejne/n323Z6OKodqMrNk who is making a Slay The Spire like game to see how he handles the cards :)
@Zlorak7 ай бұрын
@@Unain Tysm! I'll def watch it, i was looking for a resource like that one.
@UndeadMunchies5 ай бұрын
I suppose I understand how they work now. I just am struggling to understand *why* you would use them. Everything shown here does not need a resource to do in any way, and if anything is made more complicated by using them. What is a use case where a resource is the clear option over just extending off of a custom class or using a script template?
@Peak_Stone3 ай бұрын
From what I understand, it reduces references and dependencies and helps in error tracking. if there is a bug, you can to ognore respurces as they are inert. if however all your variables are stored in scripts, then you jave to reason about them not the best answer. but its the best i can do
@randomguy00714 ай бұрын
what's the difference between scene and packedscene?
@limodemh54689 ай бұрын
Thanks for the explanation! Only if something could explain Resources is like using json to save the information let's say for the characters? So this is godot's way?
@ICSkill1016 ай бұрын
I get an error: Invalid get index 'Starting_Health' (on base: 'Nil'). Why so?
@lcdcstudios5 ай бұрын
idk if you are still experiencing a problem but you might want to export your var stats: characterstats in your player character
@ICSkill1015 ай бұрын
I solved the problem, don't remeber how.
@alexnoman149810 ай бұрын
I heard you can load more of these Resources dynamically. This allows for content updates or mods. I now want to figure out how to ship a modding Godot project that allows the creation of these resources, packaging them into a blob that my game understands. Then having the resource loader, UI, and game deal with any amount or a selected subset of all available resources. If I had that, I could just ship the game with all default gameplay and assets as the default "mod". Does that sound feasible or sensible? Would any part of that make for a good tutorial video?
@Unain10 ай бұрын
Sounds feasible. Could maybe look at Brotato and see how they handle modding since that's made in Godot.
@gimgiringim40028 ай бұрын
Hi, I keep getting the error that add_child cannot be called on a null instance when using 2D nodes instead of the 3D versions. Is there any way you could help me with that?
@davids51957 ай бұрын
I'm getting a similar error for 2D nodes. For me, it's with the instantiate part. "Cannot call method 'instantiate' on a null value," it says. Never mind. I figured out my issue. I had the @export var for the PackedScene, but I had forgotten to put the desires scene into the editor. So, of course it was a null value, lol
@HurricaneSA10 ай бұрын
Hi. Let's say you want to use a resource file to spawn an item scene. In the resource file you have a field for the packed scene and type PackedScene so you can easily drop a scene in the resource file when creating the resources. Now you want to know what the item is when it's spawned so you attach the resource script to your item scene and add the item resource file in the relevant field. Except you now run into recursion because you're loading the item scene into the same item scene. Of course it's a simple fix. One can simply add a scene path to the resource file instead of reference to the scene. My question is this - Is there a way to do the above without triggering recursion? Like is there a way to not load the packed scene in the resource file when attaching it to a script in its own scene? Or is scene paths the only option?
@Unain10 ай бұрын
I wouldn't have the whole item scene in the resource file. The resource file has a name, texture/3d model and other properties. You can just have an Item scene that you can spawn with the resource file as property. The Item scene will set its own properties (texture/3d model) based on the resource file on spawn. But it sounds to me like you want to have the item be a pickup and be something you can use at the same time. Its better to split them up. What are you trying to do exactly?
@HurricaneSA10 ай бұрын
@@Unain Let's say you have multiple containers in your main scene that each spawn a weapon. Attached to the container scene is a script that has an "@export weapon_resource : WeaponResource". So for each instance of the container you simply drag the relevant resource file to the Weapon Resource field in the inspector. When the player activates a container it then looks at the attached resource file and spawns the correct weapon. Inside the resource file is a PackedScene field that holds the specific weapon scene that needs to be loaded. Doing it like that works fine but then you need the player to know what type of weapon they just picked up. So you attach add a "@export weapon_resource : WeaponResource" to your weapon scripts to easily check the weapon information. Except, you can't do that because Godot tries to instantiate the PackedScene instead of just keeping a reference. So you get infinite recursion because obviously the gun scene is going to load itself into itself forever because it keeps wanting to instantiate whatever PackedScene is in it's resource file. Now the solution is to simply use a path to the scene instead of the actual PackedScene which is fine but it would be nice if one could simple drag the relevant weapon scene onto the PackedScene field instead of having to copy paths for 50 different weapons. So yeah, I was just curious if there's a easier/better way to do this?
@Unain10 ай бұрын
@@HurricaneSA Aha, well what I would do is have a weapon_pickup_resource that has the packedscene in it (if the container only has to know the weapon to spawn). No packedscene in the weapon_resource itself. Then you can just put the weapon_resource in your weapon script. When you pick it up the weapon_pickup_resource will spawn the weapon with weapon_resource. It would mean you have to make a weapon_pickup_resource for each weapon as well though, but you can put extra information in that resource, like: special pickup sound/inventory sprite/texture/etc. This is me just spitballing, because I don't know how your weapon system is set up :).
@HurricaneSA10 ай бұрын
@@Unain I'm so stupid. After taking a break I came back to realize it was entirely unnecessary to use a resource file just to spawn a weapon, thanks to your input. So instead of making it complicated I just changed the "@export weapon_resource : WeaponResource" in the container script to "export weapon_scene" : PackedScene" scene. The weapon resource file now only contains information about the weapon and not any scenes and stuff. So container spawns scene, scene has resource file with all the data and everything works as it should. No need to worry about paths and stuff anymore. Sometimes one can really miss the obvious. Lesson learned anyway. Use resource files to store data only.
@Unain10 ай бұрын
@@HurricaneSA No worries, glad it worked out for you :)
@AgriasOaks995 ай бұрын
In nested custom resource, is it possible for the child (I'm not sure if I'm using the term correctly) resource to get the property of its parent's property?
@stabbedbyapanda5 ай бұрын
If you are saying something like BaseSkillResource -> FireSkillResource -> FireballSkillResource. It should be able to, i haven't tested it but i don't see why it wouldn't. You should be able to test it real quick, by just making a function to print something when called in the grandparent
@AgriasOaks995 ай бұрын
@@stabbedbyapanda No no no, It's more like Skill resource that has a property called effect (array) that holds another custom resource class called SkillEffect. I wonder if this SkillEffect can access the property of the Skill class where it is in
@stabbedbyapanda5 ай бұрын
@@AgriasOaks99 oh I think that's a case of using signals. Or creating a var reference to specific classes
@AgriasOaks995 ай бұрын
@@stabbedbyapanda Well in that case, could you give an example of how to use signal to communicate between custom resource .tres files please?
@stabbedbyapanda5 ай бұрын
@@AgriasOaks99 Sorry I can't i'm also learning about resources. You may not be able to communicate between resources with signals either the more i think about it, you will just have to test :/ If it doesn't work my recommendation would be to have a scene that loads your resources and then you can reference them together. (I think) This would act as a manager that handles what you want.
@pixobit58829 ай бұрын
How did you animate the video?
@Unain9 ай бұрын
motioncanvas.io/
@pixobit58829 ай бұрын
@@Unaini knew it :D
@rremnar4 ай бұрын
I always thought resource files were a compiled construct for a type of object for the Windows OS. Perhaps it's different for Godot? Regardless, this is a good tutorial, thanks.
@young_leosia_fan2 ай бұрын
Why for windows specifically?
@willirittmann19176 ай бұрын
Dont know for you guys, but for me the export variables resets too often and lose its reference, im trying to use export only for debug things or smples stuffs that i can easily redo
@shadowman_936 ай бұрын
you should better stop whistling while talking xD Thanks for the great video!