Custom Resources in Godot 4 and How to use them

  Рет қаралды 14,322

Unain

Unain

Күн бұрын

Пікірлер: 56
@HakanBacon
@HakanBacon 8 ай бұрын
Wonderful tutorial! Straight to the point with examples and visuals. Lovely work
@johnmerriam7844
@johnmerriam7844 17 күн бұрын
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
@stabbedbyapanda
@stabbedbyapanda 5 ай бұрын
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!
@chuman71
@chuman71 9 ай бұрын
Best video on custom resources for Godot 4.x I found so far! thanks!
@Bloom_HD
@Bloom_HD 8 ай бұрын
Very good visuals and explanation. Thank you so much!
@qooldeluxx
@qooldeluxx 11 ай бұрын
great job, hope to see more godot 4 tutorials, you did a great job explaining.
@oreofilledjoy302
@oreofilledjoy302 7 ай бұрын
Thank you! I've been searching everywhere for a way to load my RPG Job stats!
@brendanhall3181
@brendanhall3181 6 ай бұрын
Best introduction to resources I've found!
@Marco-L
@Marco-L 10 ай бұрын
Very nice explanation. Thank you very much.
@scottisitt
@scottisitt 7 күн бұрын
That was awesome! Thank you! Liked and subscribed.
@alaouiamine3835
@alaouiamine3835 8 ай бұрын
Thank you for the clear tutorial
@isaacdobson8760
@isaacdobson8760 3 ай бұрын
you have a wonderful voice
@danielhalond6292
@danielhalond6292 8 ай бұрын
great stuff! thanks!
@mkjyt1
@mkjyt1 8 ай бұрын
Thank you!
@Evilprince191
@Evilprince191 7 ай бұрын
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 ?
@Unain
@Unain 7 ай бұрын
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.a683
@b.c.a683 7 ай бұрын
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 ?
@Zlorak
@Zlorak 7 ай бұрын
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?
@Unain
@Unain 7 ай бұрын
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 :)
@Zlorak
@Zlorak 7 ай бұрын
@@Unain Tysm! I'll def watch it, i was looking for a resource like that one.
@UndeadMunchies
@UndeadMunchies 5 ай бұрын
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_Stone
@Peak_Stone 3 ай бұрын
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
@randomguy0071
@randomguy0071 4 ай бұрын
what's the difference between scene and packedscene?
@limodemh5468
@limodemh5468 9 ай бұрын
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?
@ICSkill101
@ICSkill101 6 ай бұрын
I get an error: Invalid get index 'Starting_Health' (on base: 'Nil'). Why so?
@lcdcstudios
@lcdcstudios 5 ай бұрын
idk if you are still experiencing a problem but you might want to export your var stats: characterstats in your player character
@ICSkill101
@ICSkill101 5 ай бұрын
I solved the problem, don't remeber how.
@alexnoman1498
@alexnoman1498 10 ай бұрын
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?
@Unain
@Unain 10 ай бұрын
Sounds feasible. Could maybe look at Brotato and see how they handle modding since that's made in Godot.
@gimgiringim4002
@gimgiringim4002 8 ай бұрын
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?
@davids5195
@davids5195 7 ай бұрын
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
@HurricaneSA
@HurricaneSA 10 ай бұрын
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?
@Unain
@Unain 10 ай бұрын
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?
@HurricaneSA
@HurricaneSA 10 ай бұрын
@@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?
@Unain
@Unain 10 ай бұрын
@@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 :).
@HurricaneSA
@HurricaneSA 10 ай бұрын
@@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.
@Unain
@Unain 10 ай бұрын
@@HurricaneSA No worries, glad it worked out for you :)
@AgriasOaks99
@AgriasOaks99 5 ай бұрын
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?
@stabbedbyapanda
@stabbedbyapanda 5 ай бұрын
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
@AgriasOaks99
@AgriasOaks99 5 ай бұрын
@@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
@stabbedbyapanda
@stabbedbyapanda 5 ай бұрын
@@AgriasOaks99 oh I think that's a case of using signals. Or creating a var reference to specific classes
@AgriasOaks99
@AgriasOaks99 5 ай бұрын
@@stabbedbyapanda Well in that case, could you give an example of how to use signal to communicate between custom resource .tres files please?
@stabbedbyapanda
@stabbedbyapanda 5 ай бұрын
@@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.
@pixobit5882
@pixobit5882 9 ай бұрын
How did you animate the video?
@Unain
@Unain 9 ай бұрын
motioncanvas.io/
@pixobit5882
@pixobit5882 9 ай бұрын
​@@Unaini knew it :D
@rremnar
@rremnar 4 ай бұрын
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_fan
@young_leosia_fan 2 ай бұрын
Why for windows specifically?
@willirittmann1917
@willirittmann1917 6 ай бұрын
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_93
@shadowman_93 6 ай бұрын
you should better stop whistling while talking xD Thanks for the great video!
@gustavo3220
@gustavo3220 8 ай бұрын
Rechourches 😂😂😂
@claytonmurray4328
@claytonmurray4328 10 ай бұрын
😬 'promosm'
Custom Resource are a MUST KNOW in Godot | Complete Tutorial
32:10
When to Use a Resource Over a Dictionary?
11:06
Coding Quests
Рет қаралды 10 М.
СИНИЙ ИНЕЙ УЖЕ ВЫШЕЛ!❄️
01:01
DO$HIK
Рет қаралды 3,3 МЛН
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН
Making a Better 2D Movement Controller (Part 1)
15:54
Unain
Рет қаралды 5 М.
Introduction to Custom Resources in Godot!
8:43
Queble
Рет қаралды 7 М.
3. React 19 - Komponenter: Grunden till återanvändbar kod
42:34
How to Use SIGNALS Correctly in Godot 4 (everything to know)
24:06
10+2 AWESOME ADDONS for GODOT 4
8:36
MrElipteach
Рет қаралды 153 М.
GML 4 User Input Change Position
20:24
Errin Odell
Рет қаралды 21
Do THIS Before You Publish Your Godot Game
3:33
StayAtHomeDev
Рет қаралды 192 М.
Exploring Abandoned Games From Our Childhood
20:00
globert
Рет қаралды 70 М.
Creating a custom tool plugin in Godot 4
10:24
Octodemy
Рет қаралды 6 М.
Меня надул школьник :( #shorts
1:00
Zlusha
Рет қаралды 2,7 МЛН