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.
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!
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
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.
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.
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.
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?
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.
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.
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.
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.
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
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 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!!
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 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
@@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.
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?
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.
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.
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.
@@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.
@@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.
@@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 😂.
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.
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!
amazing ultra cool!! thank you very much!! very helpful
You are amazing person thank you soo much for these tutorials
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
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.
sir, thank you!!
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??
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.
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.
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?
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.
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.
Love the series. How well in your opinion would this system translate to party management? Either something like Pokemon or final fantasy?
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.
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.
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
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!
Oh absolutely, it wouldn't be too difficult to be honest. I might do something like that in a future tutorial.
@@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!!
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?
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?
@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
@@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.
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?
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.
@@GeorgePence i`m fix it, the problem was that row name was not equal to id)
@@ev3ryy381 have the same sh*t. Thanks bro, you save my time!
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.
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.
@@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.
@@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.
@@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 😂.
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.