UE C++ Tutorial Series: Items, Interaction, Inventory #5: The Pickup Class

Sdílet
Vložit
  • čas přidán 11. 09. 2024
  • In this video, we create the Pickup class, which is the class used to spawn an item into the game world as an actor and allow the player to interact with it.

Komentáře • 36

  • @luhalvesbr
    @luhalvesbr Před 3 měsíci +2

    Thanks for making this tutorial! It's been quite helpful for me.
    May give you a suggestion? You can turn on the "Super Thanks" button. Thus, folks can donate $$.
    Cheers!

  • @julianaskuratovsky8701
    @julianaskuratovsky8701 Před měsícem

    amazing ultra cool!! thank you very much!! very helpful

  • @unalbulut466
    @unalbulut466 Před 9 měsíci +1

    You are amazing person thank you soo much for these tutorials

  • @UAKrogan
    @UAKrogan Před rokem +7

    44:18 i think we also need to add #if macro to the .cpp file. Without this macro packaging failed. Code from my project:
    #if WITH_EDITOR
    void APickupActor::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
    #endif

    • @GeorgePence
      @GeorgePence  Před 11 měsíci +1

      I missed this comment back when you made it, but yes you are correct. I'll make a note to talk about that the next time I record a video for this project. I think I must have added it in a future video or just at some point later because I have it in my existing copy of the code.

    • @julianaskuratovsky8701
      @julianaskuratovsky8701 Před měsícem

      sir, thank you!!

  • @C.Sanjana
    @C.Sanjana Před 6 měsíci +1

    At 40.00, the interaction widget isn't working properly. In case for armore suit is works but with potion it only displays "Press E to ".Why??

    • @GeorgePence
      @GeorgePence  Před 6 měsíci +1

      You should revisit the sections where we set up the text blocks for the action text to the interaction widget and make sure that 1. it is connected correctly to the C++ code and 2. you are setting a text value into it correctly.

    • @monkieprojects739
      @monkieprojects739 Před 3 měsíci

      I fixed this issue by opening pickup.cpp and Go to line (26 for me) where it should be
      if(ItemDataTable && !DesiredItemID.IsNone())
      I had missed the `!`
      double check that.

  • @ATK07
    @ATK07 Před měsícem

    Hey, but why make the extra steps with InstanceInteractableData if we can edit the InteractableData directly? InstanceInteractableData is only usefull if we want to edit it in the BluePrint editor, right?

    • @GeorgePence
      @GeorgePence  Před měsícem

      I think that at the time that was my logic, yes. The next video I make I plan to go through some optimizations on the interaction system since there's a few things that can be done to make it cleaner and more efficient.

  • @robinj6997
    @robinj6997 Před 7 měsíci

    I'm using your interaction system for a ship. I'm calling different components such as anchor, helm, canon, halyard and so on. And when interacting with a halyard, I want to hoist it or lower it (same thing for steering wheel and anchor). So there is one interaction of grabbing an item, then a second interaction to move it.
    Should I create a new function in the interface, and call it for example Interact1Axis(). Then call that function from a new InputAction in my character. Lastly use the Interact() function in my character to set a boolean to true which allows the Interact1Axis() to be called? Does that sound like a good idea?
    Again, thank you for sharing all of your code, it's a brilliant tutorial.

  • @mattice9083
    @mattice9083 Před 7 měsíci

    Love the series. How well in your opinion would this system translate to party management? Either something like Pokemon or final fantasy?

  • @Kersa4ok
    @Kersa4ok Před 8 měsíci +1

    PostEditChangeProperty - Interesting function, I also resolved this issue with mesh and InteractableData update by calling InitializePickup in OnConstruction method. As I understund it's more optimized to initialize stuff on construction and not on begin play, if you can ofc. But I'm not very expereenced in UE yet, so I may be wrong, please correct me, if it's the case.

    • @GeorgePence
      @GeorgePence  Před 8 měsíci

      That will work, but only once per editor session. The reason being is that Unreal C++ class constructors only run when the editor launches. This is why throughout the series you always will hear me mention closing the editor and recompiling. Live coding is a way to mitigate this some, but again, live coding will not run the constructor. Live coding is only reliable for when you change a function body, like the internal code of a function you already created prior. If you ever have to modify a constructor or a header file, you should always close the editor and recompile and relaunch to ensure things work correctly. So all of that to say... that is why the PostEditChangeProperty is needed, because you want to be able to change the item any time while the editor is open, not just when it launches.

    • @Kersa4ok
      @Kersa4ok Před 8 měsíci

      May be I wasn't clear, I'm speaking not about livecoding, but about The Construction Script, that runs when an instance of a Blueprint Class is created. In c++ it's called OnConstruction(), it's called every time you change something in actor or place or spawn

  • @Test-xt3ys
    @Test-xt3ys Před 10 měsíci

    I wonder if it's easy to let's say, open a chest, and make objects spawn from it, onto the floor, like in fortnite or warzone - excellent tutorial so far!

    • @GeorgePence
      @GeorgePence  Před 10 měsíci +1

      Oh absolutely, it wouldn't be too difficult to be honest. I might do something like that in a future tutorial.

    • @Test-xt3ys
      @Test-xt3ys Před 10 měsíci +2

      @@GeorgePence Hey George! thank you so much for this serie, I'm learning so freaking much..! Thanks to you I'll be able to implement a complete inventory system in my game :) hope you're doing good and that you'll come back soon!!

  • @Prosony1
    @Prosony1 Před 4 měsíci

    Hey there! I have problem with PostEditChangeChainProperty on UE 5.3. I was trying to override PostEditChangeChainProperty but rider was not find this function. Who know how resolve this problem?

    • @GeorgePence
      @GeorgePence  Před 4 měsíci

      Hmm... the one you should be using is just "PostEditChangeProperty", without Chain in the name... does it find it if you switch it back to that?

    • @Prosony1
      @Prosony1 Před 4 měsíci

      ​ @GeorgePence thanks for answer) i was trying to find in override modal panel in rider some function PostEdit and i find only PostEditImport(). I'm actually was trying to jump in source code UObject and i was find COREUOBJECT_API virtual void PostEditChangeChainProperty( struct FPropertyChangedChainEvent& PropertyChangedEvent ) under #if WITH_EDITOR macros. But i can't override this funct in APickup.h. I use Linux_Unreal_Engine_5.3.2

    • @GeorgePence
      @GeorgePence  Před 4 měsíci

      @@Prosony1 Ah, okay... I have never used that function. I'd recommend trying to look at the official documentation on it, and also do a search of the UE source to see where it's defined and also examine other cases in the engine code where they used it, that way you can see what needs to be done.

  • @ev3ryy381
    @ev3ryy381 Před 10 měsíci

    Hello, on ItemReference->Id = ItemData->Id; i get a crash, if i remove ItemDataTable on pickup item in editor everything is getting good. I think problem in ItemData->Id and other references ItemData (ItemNumericData, ItemTextData etc.) If i return ItemDataTable on pickup and comment ItemReference->Id = ItemData->Id; ItemReference->ItemNumericData = ItemData->ItemNumericData; etc. everything related to ItemData everything is getting good, what could be the problem?

    • @GeorgePence
      @GeorgePence  Před 10 měsíci +1

      What kind of error are you getting in the crash? If it is a nullptr exception, or if it says something like "tried to access memory at location 0x000000000000" then you have a problem with how you are setting your data table reference in the pickup, and it's null, so any time something tries to access data from it, you will get a crash. It runs when you comment those things out or remove it because the entire initialization block is getting skipped. I'd go back over the code carefully and make sure you're setting the data table in the pickup correctly. Try running the debugger on it as well to see if it is null, and the debugger will help you figure out why.

    • @ev3ryy381
      @ev3ryy381 Před 10 měsíci +1

      @@GeorgePence i`m fix it, the problem was that row name was not equal to id)

    • @Prosony1
      @Prosony1 Před 4 měsíci

      @@ev3ryy381 have the same sh*t. Thanks bro, you save my time!

  • @jackof4ll
    @jackof4ll Před 11 měsíci

    on this line: const FItemData* ItemData = ItemDataTable->?FindRow(DesiredItemID, DesiredItemID.ToString());
    I get a crash on this line where it says in the Rider logs:
    Error LogDataTable UDataTable::FindRow : 'mun_001' specified incorrect type for DataTable '/Game/Game/Items/DT_ItemData.DT_ItemData'.
    And in the Crash Logs it says this:
    UnrealEditor_CSTutorial!APickup::InitializePickup() [D:\dev\CSTutorial\Source\CSTutorial\Private\WorldActors\Pickup.cpp:32]
    I've triple checked all the values and and even changed the values but the Still getting the same crash. Even Built from scratch but this crash is consistent.

    • @GeorgePence
      @GeorgePence  Před 11 měsíci +1

      This sounds like something with how you initially set up your struct that you linked to the data table... the only thing I can think is that the template argument you are using to obtain the row (the ) is causing an issue because it's finding the designator you used, but then is unable to match it up to the correct type. I can't be much help without seeing your code, but I'd go and verify all pieces used in the chain to make sure they're all the correct types.

    • @jackof4ll
      @jackof4ll Před 11 měsíci +1

      ​@@GeorgePence First and foremost thanks a lot for replying and giving me directions.
      Secondly Apologies for late replying.
      I watched all the videos again and rechecked all the things. I'd say the problem was in fact as you said it was. I created DataTable using "FItemData" (which was based on the struct we created in the second video) and not "ItemData" which caused the type mismatch.
      Again Thanks a lot for the help.

    • @GeorgePence
      @GeorgePence  Před 11 měsíci +1

      @@jackof4ll Ahh, I see... feel free to rename things as you see fit if something seems confusing. Although I do not remember there being a duplicate name like that. FItemData should be used strictly for the data table and for obtaining info from it, but UItemBase is what you should be using for actual items that will be placed into the inventory.

    • @jackof4ll
      @jackof4ll Před 11 měsíci

      @@GeorgePence yes ItemData is the thing is should've used but in DataTable creation in editor I chose FItemData that caused this weird crash. 😂 Now I know how and what I should be doing in this regard. That was one thing I learned from yesterday 😂.

    • @The_Uncertainty
      @The_Uncertainty Před 11 měsíci +1

      I am getting the same crash. Even checked the solution that was suggested but I don’t find any name conflict with itemdata so don’t know if the datatable is getting created with different struct.