Hey mate quick question. I am using your tutorial to make an inventory and the only difference is I am using character controller to store inventory (not to lose it when different level is loaded). Everything works perfect except my picked up items are disappearing from the inventory after around 30 seconds. I am using 4.18.3. Any ideas about why this might be ? Also great tuts. Thanks man. You are a life saver.
@@charliemason7085 Hey mate. It has been a while but if I remember right in my case when I called Destroy() I called it on both the 3D model AND the stored item on my Inventory array by mistake. So both the 3D model on the level and stored item on Inventory were destroyed and garbage collector simply removed it after a short time, thus item disappearing. Hope helps ;)
5:26 Why does that have to be 'const' ? Wouldnt the inventory be changing.. using/selling items so an array of items in an inventory wont be constant and fixed right? Just making sure I understand that line of code right but its code to keep checking and updating inventory so it makes an array of the items(actors) in the array and adds items to it as you find them. Or is that the reference itself is const meaning this is an array of pointers but the array itself will be a reference and we dont want to change a reference of these inventory actors so were making it const to make sure those items in the inventory cant be changed? Also this links back to my first question posted previously about pointers, but why is the const array of actor pointers a reference? Could that line of code have been it's own variable like '(FUpdateInventoryDelegate, const TArrayPickedupItems, InventoryItems)' ?
Due to the & (address operator) the parameter in the multicast delegate is a pointer to a memory address. This pointer to the memory address has to be const, so that we always get the same array data (cause it is always the same memory address, it will always update the same array). The array is not const bu its adress is. hope that makes it more clear to you.
So yeah I have an issue i have done everything but my inventory is not update when I pick up the item. I have set a debug at the moment i touch my item i receive a message. I have a debug at the moment i add it in my c++ array and i loop and print it and everything is fine. I also enter in the function that do the broadcast thing all good too. I have set a picture to my item. The only issue is when i walk on my item i don't see the picture in my inventory i have the same inventory blueprint. Help !
I was following all these inventory tutorials up until 7:20 point of this video where you're commenting out code that isn't covered under the tutorial. What is '_inventory'? I type that and it is undeclared. I don't know what to do with that. What video did I miss? I am stuck.
2:50 So Pointers and References confuse me on when you would use one over the other. Can someone explain to me why this is has to be a pointer and not a reference? I understand pointers make copies and point to an address in memory, and that a reference points to the actual object, but I have a hard time figuring out when you would have to have a copy and not the actual object, or instead of using a pointer/reference how come it cant just be a regular variable like 'UTexture2D Image;' which I may be mistaken means it'll be passed by value. I understand that also using a pointer makes a copy, and thus adds more to the brewing pot so people like to not use pointers when possible to keep the program as small and efficient as possible. I also understand that Pointers allow you to change the object in a safe way that you're changing a copy of the original object and that changing a reference will change the actual object... So here its a Pointer to an Image file for Inventory. It makes a copy of the original image thats in file "Image" and prints that to screen. So is it a Pointer, because that image would be used multiple times and not just once so copies would be needed? Also, if it was only being used once, then could we get away with making the Image file a Reference or pass it by value?
Hi, are you familiar with the concepts stacks and heap? Please have a look at this and understand where objects are stored when created with new. Also read some documentation about refrences in C++ and copy constructors (why and when are objects copied).
First of all, pointers don't create copies, they just hold an objects memory address. In typical C++, you would a reference over a pointer almost always. They pretty much do the same thing, references pass a reference to the object and pointers pass a reference to the objects memory address. Hope that clears up your question.
Your doing very good videos Jay AnAm :) Pls don't Stop
Thank you, and no, I won't!
Amazing stuff, thank you!
Thx, you're welcome
awesome!
Thx!
Hey mate quick question.
I am using your tutorial to make an inventory and the only difference is I am using character controller to store inventory (not to lose it when different level is loaded). Everything works perfect except my picked up items are disappearing from the inventory after around 30 seconds. I am using 4.18.3. Any ideas about why this might be ?
Also great tuts. Thanks man. You are a life saver.
I've got this same problem did you or anyone find a fix?
@@charliemason7085 Hey mate.
It has been a while but if I remember right in my case when I called Destroy() I called it on both the 3D model AND the stored item on my Inventory array by mistake. So both the 3D model on the level and stored item on Inventory were destroyed and garbage collector simply removed it after a short time, thus item disappearing.
Hope helps ;)
5:26 Why does that have to be 'const' ? Wouldnt the inventory be changing.. using/selling items so an array of items in an inventory wont be constant and fixed right? Just making sure I understand that line of code right but its code to keep checking and updating inventory so it makes an array of the items(actors) in the array and adds items to it as you find them. Or is that the reference itself is const meaning this is an array of pointers but the array itself will be a reference and we dont want to change a reference of these inventory actors so were making it const to make sure those items in the inventory cant be changed?
Also this links back to my first question posted previously about pointers, but why is the const array of actor pointers a reference? Could that line of code have been it's own variable like '(FUpdateInventoryDelegate, const TArrayPickedupItems, InventoryItems)' ?
Due to the & (address operator) the parameter in the multicast delegate is a pointer to a memory address. This pointer to the memory address has to be const, so that we always get the same array data (cause it is always the same memory address, it will always update the same array).
The array is not const bu its adress is.
hope that makes it more clear to you.
So yeah I have an issue i have done everything but my inventory is not update when I pick up the item. I have set a debug at the moment i touch my item i receive a message. I have a debug at the moment i add it in my c++ array and i loop and print it and everything is fine. I also enter in the function that do the broadcast thing all good too. I have set a picture to my item. The only issue is when i walk on my item i don't see the picture in my inventory i have the same inventory blueprint. Help !
Great I found my issue i had a missing link in the inventory blueprint between the foreachloop and the set node. !
Still having an issue that sometime the items are disapearing from my inventory and the engine crash any idea ?
What's the purpose of using pointers?
Please read the basics about pointers here: www.cplusplus.com/doc/tutorial/pointers/
Pointers hold a 4byte address to the start of memory instead of declaring "health,mana,skills,items,DNA,atoms,etc" you just allocate "0x01"
I was following all these inventory tutorials up until 7:20 point of this video where you're commenting out code that isn't covered under the tutorial. What is '_inventory'? I type that and it is undeclared. I don't know what to do with that. What video did I miss? I am stuck.
sorry for the late response. yes we made a function with _Inventory
2:50 So Pointers and References confuse me on when you would use one over the other.
Can someone explain to me why this is has to be a pointer and not a reference? I understand pointers make copies and point to an address in memory, and that a reference points to the actual object, but I have a hard time figuring out when you would have to have a copy and not the actual object, or instead of using a pointer/reference how come it cant just be a regular variable like 'UTexture2D Image;' which I may be mistaken means it'll be passed by value.
I understand that also using a pointer makes a copy, and thus adds more to the brewing pot so people like to not use pointers when possible to keep the program as small and efficient as possible. I also understand that Pointers allow you to change the object in a safe way that you're changing a copy of the original object and that changing a reference will change the actual object...
So here its a Pointer to an Image file for Inventory. It makes a copy of the original image thats in file "Image" and prints that to screen. So is it a Pointer, because that image would be used multiple times and not just once so copies would be needed? Also, if it was only being used once, then could we get away with making the Image file a Reference or pass it by value?
Hi, are you familiar with the concepts stacks and heap? Please have a look at this and understand where objects are stored when created with new. Also read some documentation about refrences in C++ and copy constructors (why and when are objects copied).
First of all, pointers don't create copies, they just hold an objects memory address. In typical C++, you would a reference over a pointer almost always. They pretty much do the same thing, references pass a reference to the object and pointers pass a reference to the objects memory address. Hope that clears up your question.
how do you connect the const pickup variable with the set pickup
A broadcast is called with the list of items 07:43 . The broadcast fires an event in the blueprint.