Unreal Inventory System Course - #4 Item Drops

Поділитися
Вставка
  • Опубліковано 4 лют 2025

КОМЕНТАРІ • 16

  • @Wolfie5309
    @Wolfie5309 5 місяців тому

    a Sphere Trace For Objects works better in 3rd person rather than a line trace. A sphere trace centered on the character mesh with a radius of about 150 is good for picking up objects, opening doors, etc.

  • @TheKr0ckeR
    @TheKr0ckeR 2 місяці тому

    Its looking cool, But since I use Interaction interface for my Doors, DO i really need to add Get Inventory method? How can we make this more scalable? Maybe instead of adding IInteraction to our player, maybe adding something IInventoryOwner, so that it can get inventory from Interacting Actor?
    BTW, how did you ended up calling Inventory Constructor on BP_Chest? I was calling inside the BP_Chest's construction script, but it doesnt allow me to add items directly on the editor. So how can we add default items for chest? Do we need to add them runtime on begin play or smth?

    • @thegamedevcave
      @thegamedevcave  2 місяці тому +1

      we are doing GetInventory on the actor that interactor with the WorldItem. that should be entirely separate from the implementaion your door might have. That's the power of interfaces. you can call a function blindly on an object and then that object decides what that means. for your door, that may be opening and closing, for this item it will be adding itself to the player inventory. For a lot of interaction based stuff it's probably going to be useful to send through the interacting actor (which will usually be the player). But in case it is nto the player, that's why we use the Get Inventory interface on it, so that any object that implements that function can work with this.
      Maybe you'd want to add these functions to 2 separate interfaces if you're really worried about having all the tiny details sorted out but all in all, this is the scalable way to do things.
      As for the inventory construction on the chest, I believe you'll want to do that on begin play instead of in the construction script. the construction script runs in editor whenever it reconstructs the object (when it is being changed) so it's not a great way to drive any gameplay related things.

    • @TheKr0ckeR
      @TheKr0ckeR 2 місяці тому

      @thegamedevcave Thanks a lot for detailed answer, I am a Unity Dev for a long time and in c# interfaces, every method is obligated to implement, even ifts empty, what i was worried was, my game will have a lot of interactable objects, and only half of them need the inventory, but since they implement IInteraction interface, they automatically implement the Get Inventory method too. I dont know if thats a problem though.In c# side, i would need to add another interface like IInventoryOwner and check if interactinng actor implements it so that i can call getnventory function. So i wondered how things goes on unreal engine side. Thanks for your detailed answer again.

    • @thegamedevcave
      @thegamedevcave  2 місяці тому +1

      @@TheKr0ckeR you totally can make a separate interface for inventory specific actors! that probably would be best. although, you're also fine to just ignore any functions on an interface you're not using in a specific class (i suppose it has a slight bit of memory cost because the class DOES then contain the function still but if you dont write anything in it that'll be a matter of bytes so i probably wouldn't worry too much about it in reality, still splitting your interfaces up is the responsible thing to do!).

    • @TheKr0ckeR
      @TheKr0ckeR 2 місяці тому

      @@thegamedevcave Thanks a lot, that made me relieved.

  • @Rjmckinnon
    @Rjmckinnon 10 місяців тому

    I am loving this series, it has been super helpful!
    I am curious how to save the inventory, I have never worked with array's!
    I have a bunch of other variables saving, but can't seem to get the Arrays to work the same way!

    • @thegamedevcave
      @thegamedevcave  10 місяців тому +2

      On your save data class you should just be able to add arrays as a variable and then when saving you simple get the array you want to save, use a for each loop and add every individual entry to the save data array that way.

    • @Rjmckinnon
      @Rjmckinnon 10 місяців тому

      @@thegamedevcave Thank you so much! I also had to add a variable on the inventory comp that would check if the inventory had been built, and if so don't run the Constructor script! So far so good!!

  • @blacksage81
    @blacksage81 6 місяців тому

    Everything works as you are presenting for me until I try to manually populate an Inventory in the editor, If I do anything other than run the add rock function to the inventory, the entire array resets.

  • @Atl3m
    @Atl3m 10 місяців тому

    Good one like always 😊 thank you

  • @Melfar
    @Melfar 10 місяців тому

    Great one man, Thank you. I have a problem though. The line trace never hits any bp_world item. it hits everything but!! I don't get it. I have collisions on and everything. what did I do wrong

    • @thegamedevcave
      @thegamedevcave  10 місяців тому

      hmm strange. maybe your item's mesh collision channels are set to something weird?

    • @Melfar
      @Melfar 10 місяців тому

      @@thegamedevcave there is nothing special about it, just like any other object. the thing is, the line trace hits everything in the scene except the any child of BP_WorldItem. I am going nuts man