RPG Items in Godot Engine!

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ธ.ค. 2024

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

  • @jacobfoxe4691
    @jacobfoxe4691  9 หลายเดือนก่อน +13

    Hey Friends! Fair warning: This tutorial is a bit outdated! At some point, I'll get around to making a Godot 4+ version, but for now, I'd recommend checking out my video on the new Export syntax in Godot 4 to get started with some of the new data exporting rules!
    Thanks for the continued support! Let me know if you'd like to see this or any of my other older tutorials refreshed for the current Godot 4 landscape!

    • @domenbaumgartner8765
      @domenbaumgartner8765 9 หลายเดือนก่อน +1

      Still a great video for learning the concepts, looking forward to seeing the updated version to use in my games.

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

    2 years latet and this is still very helpful. Even with outdated syntax ( exports) and stuff, its a great video showcasing the fundemental parts of making an item system in godot. Videos like this are hard to find now because everyone just wants to show off their way to make inventories, instead of just showing people fundementals of items. So thank you even now for this fantastic video!

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

      Thanks! I really appreciate it! I'd love to do a Godot 4+ remake of this tutorial, so maybe sometime soon!

  • @LowPolyPixel
    @LowPolyPixel 2 ปีที่แล้ว +31

    This was the tutorial that I didn't know I needed. While I'm not making an RPG, this has so many use cases and now I've got ideas! Thanks for this.

    • @jacobfoxe4691
      @jacobfoxe4691  2 ปีที่แล้ว +2

      Glad you found it helpful! Resources are SO powerful, regardless of the application! It’s a bit annoying that you can’t export custom classes (yet), but hopefully that’s resolved in 4.0. Cheers!

  • @TheLateAdopter
    @TheLateAdopter ปีที่แล้ว +5

    Once he said, "lets zoom in a little bit so its easier to see", I was liek, "THANK YOU!"

  • @_gamma.
    @_gamma. 2 ปีที่แล้ว +9

    Great tutorial! HeartBeast has a couple videos where he compares them to “scriptable objects,” which is really where the structure shines IMO. JSON or CSVs can’t really compare.
    One neat thing I’ve been playing with are creating base “Item” scenes that allow me to set a resource in the inspector. It’s pretty much like your item scene in the video, but for the world instead of an inventory. Makes placing items around my levels super easy!
    Thanks for sharing the tutorial, looking forward to more!

    • @jacobfoxe4691
      @jacobfoxe4691  2 ปีที่แล้ว +8

      Thinking of Resources as Scriptable Objects is perfect! Heartbeast's video is what got me so interested in Resources in the first place - lots of love to him and his channel!
      I love that idea of creating Item scenes to be placed in the world, too! I use something like this in my current game as a wrapper around my Item Resources (a la export(Resource)) and setting up the item in the inspector OR dragging an already-made one into that Item Scene Instance)!
      Thanks for the comment!

    • @slothinahat
      @slothinahat 2 ปีที่แล้ว

      Yep same. I’m also using a base item which just reads properties from the resource while in game. It’s so much better than creating individual scenes.

  • @willigoen
    @willigoen ปีที่แล้ว +1

    So nice!, thanks for this bro! Very illustrative keep going!!!

  • @colemangentry4186
    @colemangentry4186 2 ปีที่แล้ว +2

    Thank you! This is just what I needed.

    • @jacobfoxe4691
      @jacobfoxe4691  2 ปีที่แล้ว

      Absolutely! Thanks for stopping by! :)

  • @Unknown-sr6tl
    @Unknown-sr6tl ปีที่แล้ว

    Keke's the real goat fr 🎵🎵

  • @Playburger1337
    @Playburger1337 ปีที่แล้ว +5

    Depending on your Godot version, you may run into error very early when try to code along. Starting using godot 4 there are errors when trying export or @export the very first variables. var ITEM_NAME is okey - no error, as well as @export var name: String = "" no errror ! :) It takes a while to search but u will find links for both old and new engine commands.

  • @andrewmartin5183
    @andrewmartin5183 2 ปีที่แล้ว

    Thanks for the tutorial, the idea of using extends to create the different item classes while still sharing functionality was exactly what I needed ☺

  • @mvolkankarakas
    @mvolkankarakas 2 ปีที่แล้ว +1

    u r right that the video is long. however the resource is a deep subject. now I am aware how the links works amongst the godot class structure. u r a good tutor. please go on with your way. thank you indeed.

    • @jacobfoxe4691
      @jacobfoxe4691  2 ปีที่แล้ว

      Thanks for the feedback! I'm glad you found it helpful! :)

  • @canismajoris3959
    @canismajoris3959 ปีที่แล้ว

    Thank you so much for this tutorial! I've been struggling with how to construct an item database of sorts. My current implementation uses one big singleton that contains every item and it's various parameters, but this seems much better!

  • @OldSwampo
    @OldSwampo ปีที่แล้ว

    Great tutorial! Anyone who has played around with unities scriptable objects has played with this kind of data driven design. One pitfall that I think should be mentioned is the danger of storing actual runtime data in your item data. I might have just missed this section in your video, but with this current set up, it seems that you would run into issues when different inventories have the same item type. For example you have 4 cookies in your inventory and a shopkeeper has 5 cookies, with your resource storing the quantity both you and the shopkeeper would be accessing the same resource and therefore the same quantity. There wouldn't be an easy way to buy a cookie, therefore reducing the shopkeepers quantity by one and increasing your quantity by one since they are the same variable. I think the easiest workaround would be to either store the quantity in a separate inventory management script or create an item node which references a resource for all its consts but holds all its variables separately so that any number of them can be instantiated without them interfering with each other.

  • @sbandc
    @sbandc ปีที่แล้ว

    Your voice has captured me. I am working on an interesting variation of an RPG, and your perspective would be valuable. Obviously you have your own project so I don’t expect any interest, but I’d hate myself I didn’t at least extend the chance to work with you.
    Now I will finish your voi- video.

  • @FerreusDeus
    @FerreusDeus 2 ปีที่แล้ว +1

    I got a little lost on the latter half but this was very helpful. I'm still wrapping my head around resources vs scenes and how resources are integrated. My item class is HIGHLY similar but extends nodes. I then make a scene for each item. I need to understand resources better.

    • @jacobfoxe4691
      @jacobfoxe4691  2 ปีที่แล้ว +3

      No problem - there's a lot going on behind the scenes, and the difference between some of the object types can be pretty fine. In general, you can use exported variables in nodes or resources (or any other object that extends from the Object type), so it's not necessarily wrong to use nodes.
      However, using 'extends Resource' in your script allows you to create instances of that resource from the editor window very quickly (these are the .tres files). If you're familiar with object-oriented techniques, creating the Resource script is like defining a class, while creating a Resource of that script's type is like instancing that class.
      With these .tres files created, you can then call on them in your code to load/save data quickly, and you can easily change all types of information!

    • @FerreusDeus
      @FerreusDeus 2 ปีที่แล้ว +1

      @@jacobfoxe4691 It seems extremely handy and clean. The way I was doing it, I couldn't attach a second script, so I didn't know where to add the functionality for individual items without adding it to the general item script and I intuitively knew that wasn't best practice. Thanks for taking the time to respond to me.

  • @tomtomkowski7653
    @tomtomkowski7653 2 ปีที่แล้ว +6

    Hi, I'm really curious about this workaround about cyclic dependency with singletons you were talking about here 3:50

  • @viewerck
    @viewerck 2 ปีที่แล้ว +1

    so good this tutorial! 10/10

  • @Slipping_thru_the_Seams
    @Slipping_thru_the_Seams ปีที่แล้ว +1

    this looks really exciting!! im a total beginner rn hope to learn to apply this stuff soon. I've never done any coding before LOL

  • @TheLateAdopter
    @TheLateAdopter ปีที่แล้ว +1

    Thanks for the video. Very enlightning. I did watch the end credits as well :), and I'm suprised that there arent any game dev videos of the game. The marketing wont happen by itself when you release the game. You need to build a fan base and hype. Create gamedev / showoff videos of the game atleast a year+ before launch to get some traction. (I havent seen any of your game videos. Maybel Ive missed something)

  • @Grimm-hb7ek
    @Grimm-hb7ek 2 ปีที่แล้ว

    This is a really great video

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

    How did you approach the inventory singleton? I tried to make one and I created a dictionary to store all items and a function to load them when one is added but Im pretty sure there should be a better way to do it

  • @kingveneer9380
    @kingveneer9380 ปีที่แล้ว +1

    does setget work differently in godot 4? managed to get most of it to work using your video about the new syntax, but I don't think you talk about setget

  • @Fred-ju1xs
    @Fred-ju1xs ปีที่แล้ว

    New to Godot. why did you need the pointer for the get_texture func at 15:45?
    Godot type casting doesnt cover pointers to textures?

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

    For Godot 4:
    The syntax for exports is like this
    @export var my_item : Resource
    I had to change the item_sprite script quite a bit. Here it is. Mind you I don't use the same naming conventions as him so it won't directly port over but you should easily be able to see the pattern in what needs changed.
    extends TextureRect
    @export var my_item : Resource:
    set = _set_item
    @onready var my_label = $RichTextLabel
    func _ready():
    if my_item:
    _set_item(my_item) # Initialize the item if it is set from the start
    func add_quantity(amount_added : int):
    my_item.add_quantity(amount_added)
    _update_label() # Ensure the label is updated
    func _set_item(new_item : Resource):
    print("setting item")
    my_item = new_item
    self.texture = my_item.get_texture()
    _update_label() # Update the label with the new item
    func _update_label():
    if my_label and my_item:
    my_label.bbcode_text = str(my_item.get_quantity())

    • @nuller52
      @nuller52 29 วันที่ผ่านมา +1

      You are a life saver, thank you so much for sharing!

    • @visibletoallusersonyoutube5928
      @visibletoallusersonyoutube5928 29 วันที่ผ่านมา +1

      @@nuller52 do you have a discord? Also thanks. I forgot I made this comment.

    • @nuller52
      @nuller52 29 วันที่ผ่านมา

      @@visibletoallusersonyoutube5928 Same as youtube nickname

    • @nuller52
      @nuller52 28 วันที่ผ่านมา

      @@visibletoallusersonyoutube5928 yes, same as youtube nickname

    • @visibletoallusersonyoutube5928
      @visibletoallusersonyoutube5928 28 วันที่ผ่านมา

      @@nuller52 sent

  • @McHumaty
    @McHumaty ปีที่แล้ว

    Could I fill in the resource fields with information obtained from a database? 5:16
    And if my armor has a specific ability, how should the code be constructed? 9:26

  • @slothinahat
    @slothinahat 2 ปีที่แล้ว +2

    I’m already using resources for my items, but I really like the idea of separating them into types of item. Finally my sword item won’t have a place to instance placeable objects
    Quick question though, if I had the line if inventory_item is ITEM: (ITEM being the class name), and it was talking about say the cookie which is a food_item which inherits from the ITEM class would this still return true?

    • @jacobfoxe4691
      @jacobfoxe4691  2 ปีที่แล้ว +1

      Thanks for checking out this video! I did a little test to confirm this behavior just now:
      -> "if cookie is ITEM" Returns TRUE because its class (FOOD_ITEM) inherits from the ITEM class.
      -> Likewise, "if cookie is FOOD_ITEM" ALSO returns true.
      This is typical behavior for object-oriented languages (like GDScript, and C++ that it's built on top of), and any classes that inherit other classes will also possess those member variables, functions, and un-overridden behaviors. Cheers!

  • @hozerino
    @hozerino ปีที่แล้ว

    What's the best way to insert, in those items, some properties that are more "instance-local"? For example a "condition" property in the ARMOR_ITEM, that transfers between the inventory item, the dropped item and the equipped item. What would the best solution be? I can't find a sweetspot

  • @FinrodIngoldo142
    @FinrodIngoldo142 2 ปีที่แล้ว

    Great tutorial and very helpful actually, but could you clear something up for me? Where do you put the function that gives the item it's action? For the cookie to restore health, do you put the function in the base Item class, because the cookie resource itself can't hold the function, right? Then the cookie would hold the parameters such as amount restored, single target, etc that are passed in? And the function itself would get called somewhere else, like in the battle scene or inventory screen?
    Do you use if statements to sort between functions then for restorative items, battle items, equipment (which you wouldn't eat to restore health)?
    I'm new to programming and Godot, so I'm trying to piece this bit together. Thanks!

    • @jacobfoxe4691
      @jacobfoxe4691  2 ปีที่แล้ว

      Hey Christopher! Yeah, different classes of Resources can hold their own functionality (and override those of their parents)! I just released a video about it if you'd like to check it out, and you're welcome to ask again if you need further clarification! Cheers!

    • @FinrodIngoldo142
      @FinrodIngoldo142 2 ปีที่แล้ว

      @@jacobfoxe4691 Thanks! I'll check it out this morning. It's really been puzzling me.

  • @ArabGameDev
    @ArabGameDev 2 ปีที่แล้ว +1

    stardew valley music fits perfectly

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

    In Godot 4.1 I tried this twice and each time I get to 17:25 and try and put in the white_shirt.tres I don't see the white t shirt in the editor. I did make my own white tshirt PNG, but I didn't do anything unique with the picture and it should be showing up. Did anyone else get stuck here?

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

      My guess would be a mismatch on the editor version - the syntax in this tutorial was for Godot 3.2 (I think), and it's a lot different for Godot 4+. Otherwise, I'd check to make sure you're exporting the right type of variable to drop-in the PNG. Let me know if that points you in the right direction, or if that just made for more questions haha

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

      ​@@jacobfoxe4691Well I found out that the $RichTextLabel.bbcode_text = newItem.getQuantity() has the RichTextLabel null when that line is run. For some reason the label is not being created in memory before that line of code is executed. Not familiar enough with Godot, but not sure why the child node is not being created when the ITEM_SPRITE code is running. Maybe someone else knows why this is happening on Godot 4 and not in Godot 3. I can try and load the project in Godot 3 to see if it works there. Also the bbcode_text seems to have been removed in Godot 4. It is still possible to toggle BBCode enabled in the editor, but the syntax no longer exists in the scripting editor. I was able to get this working by redoing it in Godot 3, so I must be doing something wrong in Godot 4.

  • @BartoszBielecki
    @BartoszBielecki ปีที่แล้ว

    Godot 4 definitely has exportable custom resources. It's too obviously missing piece for remotely data-driven system.

  • @Nomarr
    @Nomarr ปีที่แล้ว

    😀

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

    Um... good luck with dealing with hundreds (thousands) of unique items/characters.

  • @GrumpyIdiot
    @GrumpyIdiot ปีที่แล้ว +1

    pleaceeee make a full inventory system i really need that